Blur filter editor on escape when empty

This commit is contained in:
shamoon 2024-04-04 23:45:34 -07:00
parent 8919482511
commit 63157583f3
2 changed files with 11 additions and 2 deletions

View File

@ -1814,6 +1814,11 @@ describe('FilterEditorComponent', () => {
new KeyboardEvent('keyup', { key: 'Escape' })
)
expect(component.textFilter).toEqual('')
const blurSpy = jest.spyOn(component.textFilterInput.nativeElement, 'blur')
component.textFilterInput.nativeElement.dispatchEvent(
new KeyboardEvent('keyup', { key: 'Escape' })
)
expect(blurSpy).toHaveBeenCalled()
})
it('should adjust text filter targets if more like search', () => {

View File

@ -975,8 +975,12 @@ export class FilterEditorComponent
if (filterString.length) {
this.updateTextFilter(filterString)
}
} else if (event.key == 'Escape') {
this.resetTextField()
} else if (event.key === 'Escape') {
if (this._textFilter?.length) {
this.resetTextField()
} else {
this.textFilterInput.nativeElement.blur()
}
}
}