Skip to content

Commit

Permalink
Merge pull request #4736 from nextcloud-libraries/fix/ncappsidebar-ta…
Browse files Browse the repository at this point in the history
…bs-labelled

fix(NcSidebarTab): Ensure there is an `aria-label` if the `aria-labelledby` element does not exist
  • Loading branch information
susnux authored Nov 2, 2023
2 parents f1efe9c + 386796d commit 5f3205f
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
Original file line number Diff line number Diff line change
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
isTablistShown: () => this.hasMultipleTabs,
}
},

Expand Down
5 changes: 3 additions & 2 deletions src/components/NcAppSidebarTab/NcAppSidebarTab.vue
Original file line number Diff line number Diff line change
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="isTablistShown() ? undefined : name"
:aria-labelledby="isTablistShown() ? `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', 'isTablistShown'],

props: {
id: {
Expand Down

0 comments on commit 5f3205f

Please sign in to comment.