Re-open dropdown on enter if just closed
This commit is contained in:
parent
8d7ee4cb1a
commit
05495794e8
@ -239,6 +239,12 @@ describe('GlobalSearchComponent', () => {
|
|||||||
new KeyboardEvent('keydown', { key: 'Escape' })
|
new KeyboardEvent('keydown', { key: 'Escape' })
|
||||||
)
|
)
|
||||||
expect(blurSpy).toHaveBeenCalled()
|
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(() => {
|
it('should search on query debounce', fakeAsync(() => {
|
||||||
|
@ -265,6 +265,12 @@ export class GlobalSearchComponent implements OnInit {
|
|||||||
) {
|
) {
|
||||||
this.primaryButtons.first.nativeElement.click()
|
this.primaryButtons.first.nativeElement.click()
|
||||||
this.searchInput.nativeElement.blur()
|
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()) {
|
} else if (event.key === 'Escape' && !this.resultsDropdown.isOpen()) {
|
||||||
if (this.query?.length) {
|
if (this.query?.length) {
|
||||||
this.reset(true)
|
this.reset(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user