fix(web): animate command palette when closing (#5169)
This commit is contained in:
1 parent
67e2fe71d9
commit
36f4314ab7
3 files changed
+7
-15
No files matched your search
@@ -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({
|
||||
|
||||
@@ -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" } };
|
||||
|
||||
@@ -501,7 +501,6 @@ export function CommandPalette({ children }: { children: ReactNode }) {
|
||||
>
|
||||
{children}
|
||||
<CommandPaletteDialog
|
||||
open={state.open}
|
||||
mode={state.mode}
|
||||
openIntent={state.openIntent}
|
||||
setOpen={setOpen}
|
||||
@@ -514,7 +513,6 @@ export function CommandPalette({ children }: { children: ReactNode }) {
|
||||
}
|
||||
|
||||
function CommandPaletteDialog(props: {
|
||||
readonly open: boolean;
|
||||
readonly mode: SearchOverlayMode;
|
||||
readonly openIntent: CommandPaletteOpenIntent | null;
|
||||
readonly setOpen: (open: boolean) => void;
|
||||
@@ -523,10 +521,6 @@ function CommandPaletteDialog(props: {
|
||||
}) {
|
||||
const composerHandleRef = useComposerHandleContext();
|
||||
|
||||
if (!props.open) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<CommandDialogPopup
|
||||
aria-label={
|
||||
|
||||
Reference in new issue
Block a user