fix(theme): name controls by their visible text

WCAG 2.5.3 wants the accessible name of a control to contain its visible
text. The search button now takes its name from `buttonText` on every
screen size (the text is visually hidden on small screens instead of
removed) and no longer reads `buttonAriaLabel`; a flyout button only gets
its `label` as `aria-label` when it shows no text; the key hints in the
local search footer name their keys with hidden text instead of an
`aria-label`, which a `kbd` element cannot carry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
feat/not-found
Divyansh Singh 1 week ago
parent f35d81ac22
commit 840e5514e5

@ -94,7 +94,7 @@ useEventListener('pointerdown', (e) => {
class="button" class="button"
:aria-expanded="open" :aria-expanded="open"
:aria-controls="menuId" :aria-controls="menuId"
:aria-label="label" :aria-label="button ? undefined : label"
@pointerenter="onPointerEnter" @pointerenter="onPointerEnter"
@pointerleave="onPointerLeave" @pointerleave="onPointerLeave"
@click="toggle" @click="toggle"

@ -601,22 +601,28 @@ function onMouseMove(e: MouseEvent) {
<div class="search-keyboard-shortcuts"> <div class="search-keyboard-shortcuts">
<span> <span>
<kbd :aria-label="translate('modal.footer.navigateUpKeyAriaLabel')"> <kbd>
<span class="vpi-arrow-up navigate-icon" /> <span class="vpi-arrow-up navigate-icon" aria-hidden="true" />
<span class="visually-hidden">{{ translate('modal.footer.navigateUpKeyAriaLabel') }}</span>
</kbd> </kbd>
<kbd :aria-label="translate('modal.footer.navigateDownKeyAriaLabel')"> <kbd>
<span class="vpi-arrow-down navigate-icon" /> <span class="vpi-arrow-down navigate-icon" aria-hidden="true" />
<span class="visually-hidden">{{ translate('modal.footer.navigateDownKeyAriaLabel') }}</span>
</kbd> </kbd>
{{ translate('modal.footer.navigateText') }} {{ translate('modal.footer.navigateText') }}
</span> </span>
<span> <span>
<kbd :aria-label="translate('modal.footer.selectKeyAriaLabel')"> <kbd>
<span class="vpi-corner-down-left navigate-icon" /> <span class="vpi-corner-down-left navigate-icon" aria-hidden="true" />
<span class="visually-hidden">{{ translate('modal.footer.selectKeyAriaLabel') }}</span>
</kbd> </kbd>
{{ translate('modal.footer.selectText') }} {{ translate('modal.footer.selectText') }}
</span> </span>
<span> <span>
<kbd :aria-label="translate('modal.footer.closeKeyAriaLabel')">esc</kbd> <kbd>
<span aria-hidden="true">esc</span>
<span class="visually-hidden">{{ translate('modal.footer.closeKeyAriaLabel') }}</span>
</kbd>
{{ translate('modal.footer.closeText') }} {{ translate('modal.footer.closeText') }}
</span> </span>
</div> </div>

@ -163,7 +163,6 @@ function isEditingContent(event: KeyboardEvent): boolean {
<VPNavBarSearchButton <VPNavBarSearchButton
v-if="resolvedMode.showKeywordSearch" v-if="resolvedMode.showKeywordSearch"
:text="algoliaOptions.translations?.button?.buttonText || 'Search'" :text="algoliaOptions.translations?.button?.buttonText || 'Search'"
:aria-label="algoliaOptions.translations?.button?.buttonAriaLabel || 'Search'"
:aria-keyshortcuts="'/ control+k meta+k'" :aria-keyshortcuts="'/ control+k meta+k'"
@click="loadAndOpen('search')" @click="loadAndOpen('search')"
/> />
@ -183,7 +182,6 @@ function isEditingContent(event: KeyboardEvent): boolean {
<template v-else-if="provider === 'local'"> <template v-else-if="provider === 'local'">
<VPNavBarSearchButton <VPNavBarSearchButton
:text="algoliaOptions.translations?.button?.buttonText || 'Search'" :text="algoliaOptions.translations?.button?.buttonText || 'Search'"
:aria-label="algoliaOptions.translations?.button?.buttonAriaLabel || 'Search'"
:aria-keyshortcuts="'/ control+k meta+k'" :aria-keyshortcuts="'/ control+k meta+k'"
@click="showSearch = true" @click="showSearch = true"
/> />

@ -25,7 +25,17 @@ defineProps<{
font-size: 1.25rem; font-size: 1.25rem;
} }
.text, /* the text stays in the accessibility tree while the bar shows only the icon */
.text {
position: absolute;
width: 1px;
height: 1px;
white-space: nowrap;
clip: rect(0 0 0 0);
clip-path: inset(50%);
overflow: hidden;
}
.keys { .keys {
display: none; display: none;
} }
@ -59,7 +69,12 @@ kbd {
} }
.text { .text {
display: inline; position: static;
width: auto;
height: auto;
clip: auto;
clip-path: none;
overflow: visible;
font-size: 0.8125rem; font-size: 0.8125rem;
} }

Loading…
Cancel
Save