Skip to content

Commit

Permalink
enh(a11y): Add additional description for trigger button
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Sep 13, 2023
1 parent 289bfe2 commit c261336
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/NcHeaderMenu/NcHeaderMenu.vue
Expand Up @@ -75,6 +75,7 @@ export default {
ref="trigger"
class="header-menu__trigger button-vue"
:aria-label="ariaLabel"
:aria-describedby="description ? descriptionId : null"
:aria-controls="`header-menu-${id}`"
:aria-expanded="opened.toString()"
@click.prevent="toggleMenu">
Expand All @@ -83,6 +84,12 @@ export default {
<slot name="trigger" />
</button>

<span v-if="description"
:id="descriptionId"
class="header-menu__description hidden-visually">
{{ description }}
</span>

<!-- Visual triangle -->
<div v-show="opened" class="header-menu__carret" />

Expand Down Expand Up @@ -152,6 +159,15 @@ export default {
type: Boolean,
default: false,
},
/**
* Additional visually hidden description text for the menu
* open button
*/
description: {
type: String,
default: null,
},
},
emits: [
Expand All @@ -169,6 +185,7 @@ export default {
opened: this.open,
shortcutsDisabled: window.OCP?.Accessibility?.disableKeyboardShortcuts?.(),
triggerId: GenRandomId(),
descriptionId: GenRandomId(),
}
},
Expand Down

0 comments on commit c261336

Please sign in to comment.