Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcSidebarTab): Ensure there is an aria-label if the aria-labelledby element does not exist #4736

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading