From b4023c177b7898bbb6f7a97685bd8e1c3df83382 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 5 Jul 2024 17:57:18 +0200 Subject: [PATCH] 116404: Close modal on escape --- .../expandable-navbar-section.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts index 3b1d2f7faac..e546585c07b 100644 --- a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts +++ b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts @@ -166,9 +166,13 @@ export class ExpandableNavbarSectionComponent extends NavbarSectionComponent imp * @param event */ navigateDropdown(event: KeyboardEvent): void { - if (event.key === 'Tab') { + if (event.code === 'Tab') { this.deactivateSection(event, false); return; + } else if (event.code === 'Escape') { + this.deactivateSection(event, false); + (document.querySelector(`a[aria-controls="${this.expandableNavbarSectionId()}"]`) as HTMLElement)?.focus(); + return; } event.preventDefault(); event.stopPropagation();