Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/magic-keys.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down