Only reset on escape if filtered

This commit is contained in:
shamoon 2024-04-07 16:06:05 -07:00
parent e9b440428b
commit f643938573
2 changed files with 6 additions and 2 deletions

View File

@ -604,6 +604,7 @@ describe('DocumentListComponent', () => {
it('should support hotkeys', () => {
fixture.detectChanges()
const resetSpy = jest.spyOn(component['filterEditor'], 'resetSelected')
jest.spyOn(component, 'isFiltered', 'get').mockReturnValue(true)
component.clickTag(1)
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'escape' }))
expect(resetSpy).toHaveBeenCalled()

View File

@ -188,12 +188,15 @@ export class DocumentListComponent
})
this.hotKeyService
.addShortcut({ keys: 'escape', description: $localize`Clear selection` })
.addShortcut({
keys: 'escape',
description: $localize`Reset filters / selection`,
})
.pipe(takeUntil(this.unsubscribeNotifier))
.subscribe(() => {
if (this.list.selected.size > 0) {
this.list.selectNone()
} else {
} else if (this.isFiltered) {
this.filterEditor.resetSelected()
}
})