Fix: correctly handle global search esc key when open and button focused (#6644)

This commit is contained in:
shamoon
2024-05-09 06:41:42 -07:00
committed by GitHub
parent e7a5ebc64c
commit 3e22f033c7
2 changed files with 16 additions and 1 deletions

View File

@@ -318,6 +318,11 @@ export class GlobalSearchComponent implements OnInit {
event.preventDefault()
event.stopImmediatePropagation()
this.primaryButtons.get(this.domIndex).nativeElement.focus()
} else if (event.key === 'Escape') {
event.preventDefault()
event.stopImmediatePropagation()
this.reset(true)
this.searchInput.nativeElement.focus()
}
}
}
@@ -325,7 +330,9 @@ export class GlobalSearchComponent implements OnInit {
onButtonKeyDown(event: KeyboardEvent) {
// prevents ngBootstrap issue with keydown events
if (
!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)
!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft', 'Escape'].includes(
event.key
)
) {
event.stopImmediatePropagation()
}