Skip to content

Commit 5509d59

Browse files
authored
fix: prevent closing navigator when drag and drop on canvas (#4393)
Fixes #4158 none is confused with undefined value, replaced it with more explicit "auto".
1 parent 4945c8b commit 5509d59

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

apps/builder/app/builder/shared/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
113113
name: "clickCanvas",
114114
handler: () => {
115115
$breakpointsMenuView.set(undefined);
116-
setActiveSidebarPanel(undefined);
116+
setActiveSidebarPanel("auto");
117117
},
118118
},
119119

@@ -124,7 +124,7 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
124124
defaultHotkeys: ["meta+shift+p", "ctrl+shift+p"],
125125
handler: () => {
126126
$isPreviewMode.set($isPreviewMode.get() === false);
127-
setActiveSidebarPanel(undefined);
127+
setActiveSidebarPanel("auto");
128128
},
129129
},
130130
{

apps/builder/app/builder/shared/nano-states/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ export const $activeSidebarPanel = computed(
100100
}
101101
);
102102

103-
export const setActiveSidebarPanel = (nextPanel?: SidebarPanelName) => {
103+
/**
104+
* auto shows default panel when sidepanel is undocked and hides when docked
105+
*/
106+
export const setActiveSidebarPanel = (nextPanel: "auto" | SidebarPanelName) => {
104107
const currentPanel = $activeSidebarPanel.get();
105108
// - When navigator is open, user is trying to close the navigator.
106109
// - Navigator is closed, user is trying to close some other panel, and if navigator is undocked, it needs to be opened.
@@ -114,7 +117,7 @@ export const setActiveSidebarPanel = (nextPanel?: SidebarPanelName) => {
114117
return;
115118
}
116119
}
117-
$activeSidebarPanel_.set(nextPanel);
120+
$activeSidebarPanel_.set(nextPanel === "auto" ? undefined : nextPanel);
118121
};
119122

120123
export const toggleActiveSidebarPanel = (panel: SidebarPanelName) => {

apps/builder/app/builder/sidebar-left/sidebar-left.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export const SidebarLeft = ({ publish }: SidebarLeftProps) => {
141141
const returnTabRef = useRef<SidebarPanelName | undefined>(undefined);
142142

143143
useSubscribe("dragEnd", () => {
144-
setActiveSidebarPanel("none");
144+
setActiveSidebarPanel("auto");
145145
});
146146

147147
useOnDropEffect(() => {

0 commit comments

Comments
 (0)