Skip to content

Commit d0da656

Browse files
committed
feat(a11y): define slash kbd label as aria-keyshortcuts instead of
static text
1 parent 1591a10 commit d0da656

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

app/components/Header/SearchBox.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ defineExpose({ focus })
4040
<div class="search-box relative flex items-center">
4141
<kbd
4242
class="absolute inset-is-3 text-fg-subtle font-mono text-sm pointer-events-none transition-colors duration-200 motion-reduce:transition-none [.group:hover:not(:focus-within)_&]:text-fg/80 group-focus-within:text-accent z-1 rounded"
43+
aria-hidden="true"
4344
>
4445
/
4546
</kbd>
@@ -56,6 +57,7 @@ defineExpose({ focus })
5657
@focus="isSearchFocused = true"
5758
@blur="isSearchFocused = false"
5859
size="small"
60+
ariaKeyshortcuts="/"
5961
/>
6062
<button type="submit" class="sr-only">{{ $t('search.button') }}</button>
6163
</div>

app/components/Input/Base.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const props = withDefaults(
1414
* @default true
1515
*/
1616
noCorrect?: boolean
17+
/** Keyboard shortcut hint */
18+
ariaKeyshortcuts?: string
1719
}>(),
1820
{
1921
size: 'medium',
@@ -28,6 +30,8 @@ const emit = defineEmits<{
2830
2931
const el = useTemplateRef('el')
3032
33+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
34+
3135
defineExpose({
3236
focus: () => el.value?.focus(),
3337
blur: () => el.value?.blur(),
@@ -51,5 +55,6 @@ defineExpose({
5155
/** Catching Vue render-bug of invalid `disabled=false` attribute in the final HTML */
5256
disabled ? true : undefined
5357
"
58+
:aria-keyshortcuts="keyboardShortcutsEnabled ? ariaKeyshortcuts : undefined"
5459
/>
5560
</template>

app/pages/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ defineOgImageComponent('Default', {
7171
<div class="search-box relative flex items-center">
7272
<kbd
7373
class="absolute inset-is-4 text-fg-subtle font-mono text-lg pointer-events-none transition-colors duration-200 motion-reduce:transition-none [.group:hover:not(:focus-within)_&]:text-fg/80 group-focus-within:text-accent z-1 rounded"
74+
aria-hidden="true"
7475
>
7576
/
7677
</kbd>
@@ -87,6 +88,7 @@ defineOgImageComponent('Default', {
8788
class="w-full ps-8 pe-24"
8889
@focus="isSearchFocused = true"
8990
@blur="isSearchFocused = false"
91+
ariaKeyshortcuts="/"
9092
/>
9193

9294
<ButtonBase

0 commit comments

Comments
 (0)