Skip to content

Commit

Permalink
fix(NcSidebarTab): Ensure there is an aria-label if the `aria-label…
Browse files Browse the repository at this point in the history
…ledby` element does not exist

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Nov 1, 2023
1 parent daaec86 commit db0f8c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/NcAppSidebar/NcAppSidebarTabs.vue
Expand Up @@ -36,8 +36,8 @@
@keydown.tab.exact.prevent.stop="focusActiveTabContent"
@keydown.home.exact.prevent.stop="focusFirstTab"
@keydown.end.exact.prevent.stop="focusLastTab"
@keydown.33.exact.prevent.stop="focusFirstTab"
@keydown.34.exact.prevent.stop="focusLastTab">
@keydown.page-up.exact.prevent.stop="focusFirstTab"
@keydown.page-down.exact.prevent.stop="focusLastTab">
<NcCheckboxRadioSwitch v-for="tab in tabs"
:key="tab.id"
:aria-controls="`tab-${tab.id}`"
Expand Down Expand Up @@ -90,6 +90,8 @@ export default {
unregisterTab: this.unregisterTab,
// Getter as an alternative to Vue 2.7 computed(() => this.activeTab)
getActiveTab: () => this.activeTab,
// Used to check whether the tab header is shown so the tabs can reference the tab header for `aria-labelledby` or not
tablistShown: () => this.hasMultipleTabs,
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/components/NcAppSidebarTab/NcAppSidebarTab.vue
Expand Up @@ -27,7 +27,8 @@
<section :id="`tab-${id}`"
:class="{'app-sidebar__tab--active': isActive}"
:aria-hidden="!isActive"
:aria-labelledby="`tab-button-${id}`"
:aria-label="tablistShown() ? undefined : name"
:aria-labelledby="tablistShown() ? `tab-button-${id}` : undefined"
class="app-sidebar__tab"
tabindex="0"
role="tabpanel"
Expand All @@ -44,7 +45,7 @@
export default {
name: 'NcAppSidebarTab',
inject: ['registerTab', 'unregisterTab', 'getActiveTab'],
inject: ['registerTab', 'unregisterTab', 'getActiveTab', 'tablistShown'],
props: {
id: {
Expand Down

0 comments on commit db0f8c4

Please sign in to comment.