File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ const props = withDefaults(
2727const el = useTemplateRef (' el' )
2828
2929const keyboardShortcutsEnabled = useKeyboardShortcuts ()
30- const showKbdHint = computed (() => keyboardShortcutsEnabled .value && !! props .ariaKeyshortcuts )
3130
3231defineExpose ({
3332 focus : () => el .value ?.focus (),
@@ -64,7 +63,7 @@ defineExpose({
6463 <span v-if =" classicon" class =" size-[1em]" :class =" classicon" aria-hidden =" true" />
6564 <slot />
6665 <kbd
67- v-if =" showKbdHint "
66+ v-if =" keyboardShortcutsEnabled && ariaKeyshortcuts "
6867 data-kbd-hint
6968 class =" ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
7069 aria-hidden =" true"
Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ const isButton = computed(() => !isLink.value)
6060const isButtonSmall = computed (() => props .size === ' small' && ! isLink .value )
6161const isButtonMedium = computed (() => props .size === ' medium' && ! isLink .value )
6262const keyboardShortcutsEnabled = useKeyboardShortcuts ()
63- const showKbdHint = computed (() => keyboardShortcutsEnabled .value && !! props .ariaKeyshortcuts )
6463 </script >
6564
6665<template >
@@ -116,7 +115,7 @@ const showKbdHint = computed(() => keyboardShortcutsEnabled.value && !!props.ari
116115 aria-hidden =" true"
117116 />
118117 <kbd
119- v-if =" showKbdHint "
118+ v-if =" keyboardShortcutsEnabled && ariaKeyshortcuts "
120119 data-kbd-hint
121120 class =" ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
122121 aria-hidden =" true"
Original file line number Diff line number Diff line change @@ -104,10 +104,26 @@ export function useRelativeDates() {
104104 * Composable for accessing just the keyboard shortcuts setting.
105105 * Useful for components that only need to read this specific setting.
106106 */
107- export function useKeyboardShortcuts ( ) {
107+ export const useKeyboardShortcuts = createSharedComposable ( function useKeyboardShortcuts ( ) {
108108 const { settings } = useSettings ( )
109- return computed ( ( ) => settings . value . keyboardShortcuts )
110- }
109+ const enabled = computed ( ( ) => settings . value . keyboardShortcuts )
110+
111+ if ( import . meta. client ) {
112+ watch (
113+ enabled ,
114+ value => {
115+ if ( value ) {
116+ delete document . documentElement . dataset . kbdShortcuts
117+ } else {
118+ document . documentElement . dataset . kbdShortcuts = 'false'
119+ }
120+ } ,
121+ { immediate : true } ,
122+ )
123+ }
124+
125+ return enabled
126+ } )
111127
112128/**
113129 * Composable for managing accent color.
You can’t perform that action at this time.
0 commit comments