1
0
mirror of https://github.com/elk-zone/elk synced 2024-11-27 06:18:07 +09:00

fix: some keyboard shortcuts not working in non-english (#2324)

This commit is contained in:
Sma11X 2023-10-13 15:13:37 +08:00 committed by GitHub
parent e9f274f304
commit 1fe598f554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import { useMagicSequence } from '~/composables/magickeys'
export default defineNuxtPlugin(({ $scrollToTop }) => {
const keys = useMagicKeys()
const router = useRouter()
const i18n = useNuxtApp().$i18n
// disable shortcuts when focused on inputs (https://vueuse.org/core/usemagickeys/#conditionally-disable)
const activeElement = useActiveElement()
@ -41,7 +42,7 @@ export default defineNuxtPlugin(({ $scrollToTop }) => {
// TODO: find a better solution than clicking buttons...
document
.querySelector<HTMLElement>('[aria-roledescription=status-details]')
?.querySelector<HTMLElement>('button[aria-label=Favourite]')
?.querySelector<HTMLElement>(`button[aria-label=${i18n.t('action.favourite')}]`)
?.click()
}
whenever(logicAnd(isAuthenticated, notUsingInput, keys.f), toggleFavouriteActiveStatus)
@ -50,7 +51,7 @@ export default defineNuxtPlugin(({ $scrollToTop }) => {
// TODO: find a better solution than clicking buttons...
document
.querySelector<HTMLElement>('[aria-roledescription=status-details]')
?.querySelector<HTMLElement>('button[aria-label=Boost]')
?.querySelector<HTMLElement>(`button[aria-label=${i18n.t('action.boost')}]`)
?.click()
}
whenever(logicAnd(isAuthenticated, notUsingInput, keys.b), toggleBoostActiveStatus)