mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix: correctly handle global search esc key when open and button focused (#6644)
This commit is contained in:
parent
e7a5ebc64c
commit
3e22f033c7
@ -252,6 +252,14 @@ describe('GlobalSearchComponent', () => {
|
|||||||
const openSpy = jest.spyOn(component.resultsDropdown, 'open')
|
const openSpy = jest.spyOn(component.resultsDropdown, 'open')
|
||||||
component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' }))
|
component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' }))
|
||||||
expect(openSpy).toHaveBeenCalled()
|
expect(openSpy).toHaveBeenCalled()
|
||||||
|
|
||||||
|
component.searchInputKeyDown(
|
||||||
|
new KeyboardEvent('keydown', { key: 'ArrowDown' })
|
||||||
|
)
|
||||||
|
expect(component['currentItemIndex']).toBe(0)
|
||||||
|
const closeSpy = jest.spyOn(component.resultsDropdown, 'close')
|
||||||
|
component.dropdownKeyDown(new KeyboardEvent('keydown', { key: 'Escape' }))
|
||||||
|
expect(closeSpy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should search on query debounce', fakeAsync(() => {
|
it('should search on query debounce', fakeAsync(() => {
|
||||||
|
@ -318,6 +318,11 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopImmediatePropagation()
|
event.stopImmediatePropagation()
|
||||||
this.primaryButtons.get(this.domIndex).nativeElement.focus()
|
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) {
|
onButtonKeyDown(event: KeyboardEvent) {
|
||||||
// prevents ngBootstrap issue with keydown events
|
// prevents ngBootstrap issue with keydown events
|
||||||
if (
|
if (
|
||||||
!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)
|
!['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft', 'Escape'].includes(
|
||||||
|
event.key
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
event.stopImmediatePropagation()
|
event.stopImmediatePropagation()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user