From 74d2c1ed4453d348208c79c3bc30c7ffd6a14dfe Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:20:29 -0800 Subject: [PATCH] Enhancement: save & next / close shortcut key --- .../document-detail/document-detail.component.spec.ts | 8 ++++++++ .../document-detail/document-detail.component.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 24ef2ffad..fa8e94a84 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -1221,6 +1221,14 @@ describe('DocumentDetailComponent', () => { ) expect(saveSpy).toHaveBeenCalled() + jest.spyOn(openDocumentsService, 'isDirty').mockReturnValue(true) + jest.spyOn(component, 'hasNext').mockReturnValue(true) + const saveNextSpy = jest.spyOn(component, 'saveEditNext') + document.dispatchEvent( + new KeyboardEvent('keydown', { key: 's', ctrlKey: true, shiftKey: true }) + ) + expect(saveNextSpy).toHaveBeenCalled() + const closeSpy = jest.spyOn(component, 'close') document.dispatchEvent(new KeyboardEvent('keydown', { key: 'escape' })) expect(closeSpy).toHaveBeenCalled() diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 4fa535ea3..209beb2df 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -504,6 +504,16 @@ export class DocumentDetailComponent .subscribe(() => { if (this.openDocumentService.isDirty(this.document)) this.save() }) + + this.hotKeyService + .addShortcut({ + keys: 'control.shift.s', + description: $localize`Save and close / next`, + }) + .pipe(takeUntil(this.unsubscribeNotifier)) + .subscribe(() => { + if (this.openDocumentService.isDirty(this.document)) this.saveEditNext() + }) } ngOnDestroy(): void {