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', () => { it('should support hotkeys', () => {
fixture.detectChanges() fixture.detectChanges()
const resetSpy = jest.spyOn(component['filterEditor'], 'resetSelected') const resetSpy = jest.spyOn(component['filterEditor'], 'resetSelected')
jest.spyOn(component, 'isFiltered', 'get').mockReturnValue(true)
component.clickTag(1) component.clickTag(1)
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'escape' })) document.dispatchEvent(new KeyboardEvent('keydown', { key: 'escape' }))
expect(resetSpy).toHaveBeenCalled() expect(resetSpy).toHaveBeenCalled()

View File

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