Skip to content

Commit 64d4dd0

Browse files
committed
feat(sidebar): add ⌘B shortcut to collapse/expand sidebar
1 parent 7a33508 commit 64d4dd0

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

apps/sim/app/workspace/[workspaceId]/utils/commands-utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type CommandId =
1010
| 'accept-diff-changes'
1111
| 'add-agent'
1212
| 'add-workflow'
13+
| 'collapse-sidebar'
1314
| 'goto-logs'
1415
| 'open-search'
1516
| 'open-workflow-search-replace'
@@ -57,6 +58,11 @@ export const COMMAND_DEFINITIONS: Record<CommandId, CommandDefinition> = {
5758
shortcut: 'Mod+Shift+P',
5859
allowInEditable: false,
5960
},
61+
'collapse-sidebar': {
62+
id: 'collapse-sidebar',
63+
shortcut: 'Mod+B',
64+
allowInEditable: true,
65+
},
6066
'goto-logs': {
6167
id: 'goto-logs',
6268
shortcut: 'Mod+L',

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,20 @@ export function SidebarTooltip({
118118
label,
119119
enabled,
120120
side = 'right',
121+
shortcut,
121122
}: {
122123
children: React.ReactElement
123124
label: string
124125
enabled: boolean
125126
side?: 'right' | 'bottom'
127+
shortcut?: string
126128
}) {
127129
if (!enabled) return children
128130
return (
129131
<Tooltip.Root>
130132
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
131133
<Tooltip.Content side={side}>
132-
<p>{label}</p>
134+
{shortcut ? <Tooltip.Shortcut keys={shortcut}>{label}</Tooltip.Shortcut> : <p>{label}</p>}
133135
</Tooltip.Content>
134136
</Tooltip.Root>
135137
)
@@ -1218,6 +1220,12 @@ export const Sidebar = memo(function Sidebar() {
12181220
handleCreateWorkflow()
12191221
},
12201222
},
1223+
{
1224+
id: 'collapse-sidebar',
1225+
handler: () => {
1226+
toggleCollapsed()
1227+
},
1228+
},
12211229
])
12221230
)
12231231

@@ -1268,7 +1276,12 @@ export const Sidebar = memo(function Sidebar() {
12681276
isCollapsed={isCollapsed}
12691277
onExpandSidebar={toggleCollapsed}
12701278
/>
1271-
<SidebarTooltip label='Collapse sidebar' enabled={!isCollapsed} side='bottom'>
1279+
<SidebarTooltip
1280+
label='Collapse sidebar'
1281+
enabled={!isCollapsed}
1282+
side='bottom'
1283+
shortcut={isMac ? '⌘B' : 'Ctrl+B'}
1284+
>
12721285
<button
12731286
type='button'
12741287
onClick={toggleCollapsed}

0 commit comments

Comments
 (0)