mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Fix: correctly handle global search esc key when open and button focused (#6644)
This commit is contained in:
		| @@ -252,6 +252,14 @@ describe('GlobalSearchComponent', () => { | ||||
|     const openSpy = jest.spyOn(component.resultsDropdown, 'open') | ||||
|     component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' })) | ||||
|     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(() => { | ||||
|   | ||||
| @@ -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() | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon