From 313ff7a24fce3dd278bf88bfc64b4aa66ddf01ab Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 26 Apr 2026 01:06:36 +0200 Subject: [PATCH] fix(command-palette): enhance command palette management with dialog reference Entire-Checkpoint: c6e522b4276c --- .../services/workspace-shell.facade.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell.facade.ts b/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell.facade.ts index e526c8191..1e1c94d04 100644 --- a/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell.facade.ts +++ b/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell.facade.ts @@ -7,7 +7,7 @@ import { signal, } from '@angular/core'; import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; -import { MatDialog } from '@angular/material/dialog'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { NavigationEnd, Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; @@ -116,6 +116,10 @@ export class WorkspaceShellFacade { private searchDebounceTimeoutId: ReturnType | null = null; + private commandPaletteRef: MatDialogRef< + WorkspaceCommandPaletteComponent, + WorkspaceCommandSelection | undefined + > | null = null; private readonly onDocumentKeydown = (event: KeyboardEvent): void => { if (!(event.ctrlKey || event.metaKey)) { return; @@ -770,6 +774,11 @@ export class WorkspaceShellFacade { } openCommandPalette(): void { + if (this.commandPaletteRef) { + this.commandPaletteRef.close(); + return; + } + const commands = this.commandPaletteCommands(); const dialogRef = this.dialog.open< WorkspaceCommandPaletteComponent, @@ -785,11 +794,13 @@ export class WorkspaceShellFacade { query: this.searchQuery(), }, }); + this.commandPaletteRef = dialogRef; dialogRef .afterClosed() .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((selection) => { + this.commandPaletteRef = null; if (!selection) { return; }