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

zio/stable
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
1 changed files with 3 additions and 2 deletions

View File

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