Skip to content

Commit d7549d9

Browse files
committed
improvement: panel tabs handler on click
1 parent 75f55c8 commit d7549d9

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed

apps/sim/hooks/use-collaborative-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ export function useCollaborativeWorkflow() {
889889
}
890890
findAllDescendants(id)
891891

892-
// If the currently edited block is among the blocks being removed, clear selection to restore the last tab
892+
// If the currently edited block is among the blocks being removed, clear selection to reset the panel
893893
const currentEditedBlockId = usePanelEditorStore.getState().currentBlockId
894894
if (currentEditedBlockId && blocksToRemove.has(currentEditedBlockId)) {
895895
usePanelEditorStore.getState().clearCurrentBlock()

apps/sim/stores/panel-new/editor/store.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,18 @@ export const usePanelEditorStore = create<PanelEditorState>()(
4242
setCurrentBlockId: (blockId) => {
4343
set({ currentBlockId: blockId })
4444

45-
// When a block is selected, switch to editor tab and remember previous tab
45+
// When a block is selected, always switch to the editor tab
4646
if (blockId !== null) {
4747
const panelState = usePanelStore.getState()
48-
const currentTab = panelState.activeTab
49-
50-
// Only save the previous tab if we're not already on the editor tab
51-
if (currentTab !== 'editor') {
52-
panelState.setPreviousTab(currentTab)
53-
panelState.setActiveTab('editor')
54-
}
48+
panelState.setActiveTab('editor')
5549
}
5650
},
5751
clearCurrentBlock: () => {
5852
set({ currentBlockId: null })
5953

60-
// When selection is cleared, restore the previous tab
54+
// When selection is cleared (e.g. clicking on the canvas), switch to the toolbar tab
6155
const panelState = usePanelStore.getState()
62-
const previousTab = panelState.previousTab
63-
64-
if (previousTab !== null) {
65-
panelState.setActiveTab(previousTab)
66-
panelState.setPreviousTab(null)
67-
}
56+
panelState.setActiveTab('toolbar')
6857
},
6958
setConnectionsHeight: (height) => {
7059
const clampedHeight = Math.max(

apps/sim/stores/panel-new/store.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export const usePanelStore = create<PanelState>()(
3434
document.documentElement.removeAttribute('data-panel-active-tab')
3535
}
3636
},
37-
previousTab: null,
38-
setPreviousTab: (tab) => {
39-
set({ previousTab: tab })
40-
},
4137
_hasHydrated: false,
4238
setHasHydrated: (hasHydrated) => {
4339
set({ _hasHydrated: hasHydrated })

apps/sim/stores/panel-new/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ export interface PanelState {
1111
setPanelWidth: (width: number) => void
1212
activeTab: PanelTab
1313
setActiveTab: (tab: PanelTab) => void
14-
/** The tab that was active before switching to the editor */
15-
previousTab: PanelTab | null
16-
setPreviousTab: (tab: PanelTab | null) => void
1714
_hasHydrated: boolean
1815
setHasHydrated: (hasHydrated: boolean) => void
1916
}

0 commit comments

Comments
 (0)