Skip to content

Commit

Permalink
Merge e7617a2 into cc73197
Browse files Browse the repository at this point in the history
  • Loading branch information
petarmarkov9449 authored Dec 19, 2024
2 parents cc73197 + e7617a2 commit 277ea54
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@ export interface FeatureTogglesInterface {
*/
a11yAddPaddingToCarouselPanel?: boolean;

/**
* Removes invalid aria-level usage on button elements and ensures buttons have a proper accessible name via aria-label or aria-labelledby.
* Affects: NavigationUIComponent
*/
a11yButtonAriaFixes?: boolean;

/**
* Hides the 'Consent Management' button from the tab order when the cookies banner is visible.
* Ensures the button is re-enabled and part of the tab order once consent is given and the banner disappears.
Expand Down Expand Up @@ -1049,6 +1055,7 @@ export const defaultFeatureToggles: Required<FeatureTogglesInterface> = {
a11yDifferentiateFocusedAndSelected: false,
a11yKeyboardFocusInSearchBox: false,
a11yAddPaddingToCarouselPanel: false,
a11yButtonAriaFixes: false,
a11yHideConsentButtonWhenBannerVisible: false,
occCartNameAndDescriptionInHttpRequestBody: false,
cmsBottomHeaderSlotUsingFlexStyles: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ if (environment.cpq) {
a11yDifferentiateFocusedAndSelected: true,
a11yKeyboardFocusInSearchBox: true,
a11yAddPaddingToCarouselPanel: true,
a11yButtonAriaFixes: true,
a11yHideConsentButtonWhenBannerVisible: true,
cmsBottomHeaderSlotUsingFlexStyles: true,
useSiteThemeService: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,50 @@
</button>
</ng-container>
<ng-container *cxFeature="'a11yNavigationUiKeyboardControls'">
<button
aria-level="4"
[attr.role]="(isDesktop$ | async) && depth ? 'heading' : 'button'"
[attr.aria-haspopup]="true"
[attr.aria-expanded]="false"
[attr.aria-controls]="node.title"
[attr.aria-describedby]="'greeting'"
(click)="toggleOpen($any($event))"
(mouseenter)="onMouseEnter($event)"
(keydown.space)="onSpace($any($event))"
(keydown.enter)="onSpace($any($event))"
(keydown.esc)="back()"
(keydown.arrowDown)="focusOnNode($any($event))"
(focus)="depth || reinitializeMenu()"
>
<ng-container *ngIf="!node.url">
{{ node.title }}
</ng-container>
<cx-icon [type]="iconType.CARET_DOWN"></cx-icon>
</button>
<ng-container *cxFeature="'!a11yButtonAriaFixes'">
<button
aria-level="4"
[attr.role]="(isDesktop$ | async) && depth ? 'heading' : 'button'"
[attr.aria-haspopup]="true"
[attr.aria-expanded]="false"
[attr.aria-controls]="node.title"
[attr.aria-describedby]="'greeting'"
(click)="toggleOpen($any($event))"
(mouseenter)="onMouseEnter($event)"
(keydown.space)="onSpace($any($event))"
(keydown.enter)="onSpace($any($event))"
(keydown.esc)="back()"
(keydown.arrowDown)="focusOnNode($any($event))"
(focus)="depth || reinitializeMenu()"
>
<ng-container *ngIf="!node.url">
{{ node.title }}
</ng-container>
<cx-icon [type]="iconType.CARET_DOWN"></cx-icon>
</button>
</ng-container>
<ng-container *cxFeature="'a11yButtonAriaFixes'">
<button
[attr.role]="(isDesktop$ | async) && depth ? 'heading' : 'button'"
[attr.aria-haspopup]="true"
[attr.aria-expanded]="false"
[attr.aria-label]="getAriaLabelAndControl(node)"
[attr.aria-controls]="getAriaLabelAndControl(node)"
[attr.aria-describedby]="getAriaDescribedbyOfButton(node)"
(click)="toggleOpen($any($event))"
(mouseenter)="onMouseEnter($event)"
(keydown.space)="onSpace($any($event))"
(keydown.enter)="onSpace($any($event))"
(keydown.esc)="back()"
(keydown.arrowDown)="focusOnNode($any($event))"
(focus)="depth || reinitializeMenu()"
>
<ng-container *ngIf="!node.url">
{{ node.title }}
</ng-container>
<cx-icon [type]="iconType.CARET_DOWN"></cx-icon>
</button>
</ng-container>
</ng-container>
</ng-container>
<ng-template #title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,18 @@ export class NavigationUIComponent implements OnInit, OnDestroy {
}
return depth > 0 && !node?.children ? -1 : 0;
}

/**
* Returns the ID for the `aria-describedby` attribute of a button.
*/
getAriaDescribedbyOfButton(node: NavigationNode): string | null {
return node.title === 'My Account' ? 'greeting' : null;
}

/**
* Returns the value for the `aria-control` and the `aria-label` attribute of a button.
*/
getAriaLabelAndControl(node: NavigationNode): string | null {
return node.title || null;
}
}

0 comments on commit 277ea54

Please sign in to comment.