Re-open dropdown on enter if just closed

This commit is contained in:
shamoon 2024-04-14 22:02:50 -07:00
parent 8d7ee4cb1a
commit 05495794e8
2 changed files with 12 additions and 0 deletions

View File

@ -239,6 +239,12 @@ describe('GlobalSearchComponent', () => {
new KeyboardEvent('keydown', { key: 'Escape' })
)
expect(blurSpy).toHaveBeenCalled()
component.searchResults = { total: 1 } as any
component.resultsDropdown.close()
const openSpy = jest.spyOn(component.resultsDropdown, 'open')
component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' }))
expect(openSpy).toHaveBeenCalled()
})
it('should search on query debounce', fakeAsync(() => {

View File

@ -265,6 +265,12 @@ export class GlobalSearchComponent implements OnInit {
) {
this.primaryButtons.first.nativeElement.click()
this.searchInput.nativeElement.blur()
} else if (
event.key === 'Enter' &&
this.searchResults?.total &&
!this.resultsDropdown.isOpen()
) {
this.resultsDropdown.open()
} else if (event.key === 'Escape' && !this.resultsDropdown.isOpen()) {
if (this.query?.length) {
this.reset(true)