Skip to content

Commit

Permalink
[ACS-4257] - Resolved a11y issue around jumping focus (#8168)
Browse files Browse the repository at this point in the history
* ACS-4257 - Clicking on filter buttons on search results no longer switches focus from button to first element

* [ACS-4257] Added key listeners to open and close the menus to improve keyboard only usability

* ACS-4257 - Clicking on filter buttons on search results no longer switches focus from button to first element

* [ACS-4257] Added key listeners to open and close the menus to improve keyboard only usability

---------

Co-authored-by: suneet-gupta <suneet.gupta@hyland.com>
  • Loading branch information
swapnil-verma-gl and suneet-gupta authored Feb 14, 2023
1 parent a1ec61f commit 275d30b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[matMenuTriggerFor]="menu"
(onMenuOpen)="onMenuOpen()"
(keydown.enter)="onEnterKeydown()"
(keydown.escape)="onEscKeydown()"
[attr.title]="facetField.displayValue$ | async"
#menuTrigger="matMenuTrigger">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class SearchFacetChipComponent {
onMenuOpen() {
if (this.menuContainer && !this.focusTrap) {
this.focusTrap = this.focusTrapFactory.create(this.menuContainer.nativeElement);
this.focusTrap.focusInitialElement();
}
}

Expand All @@ -66,6 +65,16 @@ export class SearchFacetChipComponent {
}

onEnterKeydown(): void {
this.menuTrigger.openMenu();
if (!this.menuTrigger.menuOpen) {
this.menuTrigger.openMenu();
} else {
this.menuTrigger.closeMenu();
}
}

onEscKeydown() {
if (this.menuTrigger.menuOpen) {
this.menuTrigger.closeMenu();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[matMenuTriggerFor]="menu"
(onMenuOpen)="onMenuOpen()"
(keydown.enter)="onEnterKeydown()"
(keydown.escape)="onEscKeydown()"
[attr.title]="widget.getDisplayValue() | async"
#menuTrigger="matMenuTrigger">
<span class="adf-search-filter-placeholder">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class SearchWidgetChipComponent {
onMenuOpen() {
if (this.menuContainer && !this.focusTrap) {
this.focusTrap = this.focusTrapFactory.create(this.menuContainer.nativeElement);
this.focusTrap.focusInitialElement();
}
}

Expand All @@ -67,6 +66,16 @@ export class SearchWidgetChipComponent {
}

onEnterKeydown(): void {
this.menuTrigger.openMenu();
if (!this.menuTrigger.menuOpen) {
this.menuTrigger.openMenu();
} else {
this.menuTrigger.closeMenu();
}
}

onEscKeydown() {
if (this.menuTrigger.menuOpen) {
this.menuTrigger.closeMenu();
}
}
}

0 comments on commit 275d30b

Please sign in to comment.