| author | |
| committer | |
| log | 36f4314ab768dca3fc20af6ac25e7011b4b0447f |
| tree | 29418d40bebb31106dc218237580bca2b16206b3 |
| parent | 67e2fe71d937b45384a53c4e0addd9a167aed885 |
| signature | Signed by PGP key B5690EEEBB952194 |
3 files changed, 7 insertions(+), 15 deletions(-)
apps/web/src/components/CommandPalette.logic.test.ts+3-3| ... | ... | @@ -59,7 +59,7 @@ describe("reduceCommandPaletteUiState", () => { |
| 59 | 59 | |
| 60 | 60 | expect( |
| 61 | 61 | reduceCommandPaletteUiState(contentOpen, { _tag: "ToggleMode", mode: "content" }), |
| 62 | ).toEqual({ open: false, mode: "command", openIntent: null }); | |
| 62 | ).toEqual({ open: false, mode: "content", openIntent: null }); | |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | 65 | it("switches between open modes without closing", () => { |
| ... | ... | @@ -93,7 +93,7 @@ describe("reduceCommandPaletteUiState", () => { |
| 93 | 93 | }); |
| 94 | 94 | }); |
| 95 | 95 | |
| 96 | it("resets to command mode for dialog-driven opens and closes", () => { | |
| 96 | it("preserves the mode on close and resets it on open", () => { | |
| 97 | 97 | const filesOpen = reduceCommandPaletteUiState(closedState, { |
| 98 | 98 | _tag: "ToggleMode", |
| 99 | 99 | mode: "files", |
| ... | ... | @@ -101,7 +101,7 @@ describe("reduceCommandPaletteUiState", () => { |
| 101 | 101 | |
| 102 | 102 | expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: false })).toEqual({ |
| 103 | 103 | open: false, |
| 104 | mode: "command", | |
| 104 | mode: "files", | |
| 105 | 105 | openIntent: null, |
| 106 | 106 | }); |
| 107 | 107 | expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: true })).toEqual({ |
apps/web/src/components/CommandPalette.logic.ts+4-6| ... | ... | @@ -60,14 +60,12 @@ export function reduceCommandPaletteUiState( |
| 60 | 60 | ): CommandPaletteUiState { |
| 61 | 61 | switch (action._tag) { |
| 62 | 62 | case "SetOpen": |
| 63 | return { | |
| 64 | open: action.open, | |
| 65 | mode: "command", | |
| 66 | openIntent: action.open ? state.openIntent : null, | |
| 67 | }; | |
| 63 | return action.open | |
| 64 | ? { open: true, mode: "command", openIntent: state.openIntent } | |
| 65 | : { ...state, open: false, openIntent: null }; | |
| 68 | 66 | case "ToggleMode": |
| 69 | 67 | return state.open && state.mode === action.mode |
| 70 | ? { open: false, mode: "command", openIntent: null } | |
| 68 | ? { ...state, open: false, openIntent: null } | |
| 71 | 69 | : { open: true, mode: action.mode, openIntent: null }; |
| 72 | 70 | case "OpenAddProject": |
| 73 | 71 | return { open: true, mode: "command", openIntent: { kind: "add-project" } }; |
apps/web/src/components/CommandPalette.tsx-6| ... | ... | @@ -501,7 +501,6 @@ export function CommandPalette({ children }: { children: ReactNode }) { |
| 501 | 501 | > |
| 502 | 502 | {children} |
| 503 | 503 | <CommandPaletteDialog |
| 504 | open={state.open} | |
| 505 | 504 | mode={state.mode} |
| 506 | 505 | openIntent={state.openIntent} |
| 507 | 506 | setOpen={setOpen} |
| ... | ... | @@ -514,7 +513,6 @@ export function CommandPalette({ children }: { children: ReactNode }) { |
| 514 | 513 | } |
| 515 | 514 | |
| 516 | 515 | function CommandPaletteDialog(props: { |
| 517 | readonly open: boolean; | |
| 518 | 516 | readonly mode: SearchOverlayMode; |
| 519 | 517 | readonly openIntent: CommandPaletteOpenIntent | null; |
| 520 | 518 | readonly setOpen: (open: boolean) => void; |
| ... | ... | @@ -523,10 +521,6 @@ function CommandPaletteDialog(props: { |
| 523 | 521 | }) { |
| 524 | 522 | const composerHandleRef = useComposerHandleContext(); |
| 525 | 523 | |
| 526 | if (!props.open) { | |
| 527 | return null; | |
| 528 | } | |
| 529 | ||
| 530 | 524 | return ( |
| 531 | 525 | <CommandDialogPopup |
| 532 | 526 | aria-label={ |