Skip to content

Commit 1711004

Browse files
committed
improvement(sidebar): add keyboard shortcuts for new workflow/task, center search modal, fix edge ARIA
1 parent e6ebb91 commit 1711004

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import type { GlobalCommand } from '@/app/workspace/[workspaceId]/providers/glob
99
export type CommandId =
1010
| 'accept-diff-changes'
1111
| 'add-agent'
12+
| 'add-workflow'
13+
| 'add-task'
1214
// | 'goto-templates'
1315
| 'goto-logs'
1416
| 'open-search'
@@ -52,6 +54,16 @@ export const COMMAND_DEFINITIONS: Record<CommandId, CommandDefinition> = {
5254
shortcut: 'Mod+Shift+A',
5355
allowInEditable: true,
5456
},
57+
'add-workflow': {
58+
id: 'add-workflow',
59+
shortcut: 'Mod+Shift+W',
60+
allowInEditable: false,
61+
},
62+
'add-task': {
63+
id: 'add-task',
64+
shortcut: 'Mod+Shift+K',
65+
allowInEditable: false,
66+
},
5567
// 'goto-templates': {
5668
// id: 'goto-templates',
5769
// shortcut: 'Mod+Y',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ export function SearchModal({
343343
'-translate-x-1/2 fixed top-[15%] z-50 w-[500px] rounded-xl border-[4px] border-black/[0.06] bg-[var(--bg)] shadow-[0_24px_80px_-16px_rgba(0,0,0,0.15)] dark:border-white/[0.06] dark:shadow-[0_24px_80px_-16px_rgba(0,0,0,0.4)]',
344344
open ? 'visible opacity-100' : 'invisible opacity-0'
345345
)}
346-
style={{ left: '50%' }}
346+
style={{ left: 'calc(var(--sidebar-width) / 2 + 50%)' }}
347347
>
348348
<Command label='Search' shouldFilter={false}>
349349
<div className='mx-2 mt-2 mb-1 flex items-center gap-1.5 rounded-lg border border-[var(--border-1)] bg-[var(--surface-5)] px-2 dark:bg-[var(--surface-4)]'>

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
} from '@/components/emcn/icons'
3838
import { useSession } from '@/lib/auth/auth-client'
3939
import { cn } from '@/lib/core/utils/cn'
40+
import { isMacPlatform } from '@/lib/core/utils/platform'
4041
import {
4142
START_NAV_TOUR_EVENT,
4243
START_WORKFLOW_TOUR_EVENT,
@@ -322,6 +323,8 @@ export const Sidebar = memo(function Sidebar() {
322323
isCollapsedRef.current = isCollapsed
323324
}, [isCollapsed])
324325

326+
const isMac = useMemo(() => isMacPlatform(), [])
327+
325328
// Delay collapsed tooltips until the width transition finishes.
326329
const [showCollapsedTooltips, setShowCollapsedTooltips] = useState(isCollapsed)
327330

@@ -1065,6 +1068,16 @@ export const Sidebar = memo(function Sidebar() {
10651068
// Stable callback for DeleteModal close
10661069
const handleCloseTaskDeleteModal = useCallback(() => setIsTaskDeleteModalOpen(false), [])
10671070

1071+
const handleEdgeKeyDown = useCallback(
1072+
(e: React.KeyboardEvent) => {
1073+
if (isCollapsed && (e.key === 'Enter' || e.key === ' ')) {
1074+
e.preventDefault()
1075+
toggleCollapsed()
1076+
}
1077+
},
1078+
[isCollapsed, toggleCollapsed]
1079+
)
1080+
10681081
// Stable handler for help modal open from dropdown
10691082
const handleOpenHelpFromMenu = useCallback(() => setIsHelpModalOpen(true), [])
10701083

@@ -1153,6 +1166,18 @@ export const Sidebar = memo(function Sidebar() {
11531166
openSearchModal()
11541167
},
11551168
},
1169+
{
1170+
id: 'add-workflow',
1171+
handler: () => {
1172+
handleCreateWorkflow()
1173+
},
1174+
},
1175+
{
1176+
id: 'add-task',
1177+
handler: () => {
1178+
handleNewTask()
1179+
},
1180+
},
11561181
])
11571182
)
11581183

@@ -1334,6 +1359,9 @@ export const Sidebar = memo(function Sidebar() {
13341359
</Tooltip.Trigger>
13351360
<Tooltip.Content>
13361361
<p>New task</p>
1362+
<p className='text-[var(--text-muted)]'>
1363+
{isMac ? '⌘⇧K' : 'Ctrl+Shift+K'}
1364+
</p>
13371365
</Tooltip.Content>
13381366
</Tooltip.Root>
13391367
</div>
@@ -1500,6 +1528,11 @@ export const Sidebar = memo(function Sidebar() {
15001528
</Tooltip.Trigger>
15011529
<Tooltip.Content>
15021530
<p>{isCreatingWorkflow ? 'Creating workflow...' : 'New workflow'}</p>
1531+
{!isCreatingWorkflow && (
1532+
<p className='text-[var(--text-muted)]'>
1533+
{isMac ? '⌘⇧W' : 'Ctrl+Shift+W'}
1534+
</p>
1535+
)}
15031536
</Tooltip.Content>
15041537
</Tooltip.Root>
15051538
</div>
@@ -1696,9 +1729,11 @@ export const Sidebar = memo(function Sidebar() {
16961729
)}
16971730
onMouseDown={isCollapsed ? undefined : handleMouseDown}
16981731
onClick={isCollapsed ? toggleCollapsed : undefined}
1699-
role='separator'
1700-
aria-orientation='vertical'
1701-
aria-label='Sidebar edge'
1732+
onKeyDown={isCollapsed ? handleEdgeKeyDown : undefined}
1733+
role={isCollapsed ? 'button' : 'separator'}
1734+
tabIndex={isCollapsed ? 0 : undefined}
1735+
aria-orientation={isCollapsed ? undefined : 'vertical'}
1736+
aria-label={isCollapsed ? 'Expand sidebar' : 'Resize sidebar'}
17021737
/>
17031738
)}
17041739
</div>

0 commit comments

Comments
 (0)