From 36f4314ab768dca3fc20af6ac25e7011b4b0447f Mon Sep 17 00:00:00 2001 From: Taras Date: Wed, 19 Aug 2026 08:53:42 +0300 Subject: [PATCH] fix(web): animate command palette when closing (#5169) --- apps/web/src/components/CommandPalette.logic.test.ts | 6 +++--- apps/web/src/components/CommandPalette.logic.ts | 10 ++++------ apps/web/src/components/CommandPalette.tsx | 6 ------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.ts index 9bae9c58a977d4f82171eea74e6039051a804362..d521c119303d244f4dd629c8f9c75d920ba0ae7a 100644 --- a/apps/web/src/components/CommandPalette.logic.test.ts +++ b/apps/web/src/components/CommandPalette.logic.test.ts @@ -59,7 +59,7 @@ describe("reduceCommandPaletteUiState", () => { expect( reduceCommandPaletteUiState(contentOpen, { _tag: "ToggleMode", mode: "content" }), - ).toEqual({ open: false, mode: "command", openIntent: null }); + ).toEqual({ open: false, mode: "content", openIntent: null }); }); it("switches between open modes without closing", () => { @@ -93,7 +93,7 @@ describe("reduceCommandPaletteUiState", () => { }); }); - it("resets to command mode for dialog-driven opens and closes", () => { + it("preserves the mode on close and resets it on open", () => { const filesOpen = reduceCommandPaletteUiState(closedState, { _tag: "ToggleMode", mode: "files", @@ -101,7 +101,7 @@ describe("reduceCommandPaletteUiState", () => { expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: false })).toEqual({ open: false, - mode: "command", + mode: "files", openIntent: null, }); expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: true })).toEqual({ diff --git a/apps/web/src/components/CommandPalette.logic.ts b/apps/web/src/components/CommandPalette.logic.ts index 1fddb4f92f4a92167e8d2f9919e9247f785c1f14..688a8a8ea7916944ce6f1c327e252cf82705294a 100644 --- a/apps/web/src/components/CommandPalette.logic.ts +++ b/apps/web/src/components/CommandPalette.logic.ts @@ -60,14 +60,12 @@ export function reduceCommandPaletteUiState( ): CommandPaletteUiState { switch (action._tag) { case "SetOpen": - return { - open: action.open, - mode: "command", - openIntent: action.open ? state.openIntent : null, - }; + return action.open + ? { open: true, mode: "command", openIntent: state.openIntent } + : { ...state, open: false, openIntent: null }; case "ToggleMode": return state.open && state.mode === action.mode - ? { open: false, mode: "command", openIntent: null } + ? { ...state, open: false, openIntent: null } : { open: true, mode: action.mode, openIntent: null }; case "OpenAddProject": return { open: true, mode: "command", openIntent: { kind: "add-project" } }; diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index 4a90f1a50343903697903fdeb48db3ead64e3014..b96eac7b0d71b28cf28b4e18e855a051eb38e350 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -501,7 +501,6 @@ export function CommandPalette({ children }: { children: ReactNode }) { > {children} void; @@ -523,10 +521,6 @@ function CommandPaletteDialog(props: { }) { const composerHandleRef = useComposerHandleContext(); - if (!props.open) { - return null; - } - return (