Skip to content

Commit c04f36d

Browse files
committed
fix(sidebar): cmd+click opens in new tab, shift+click for range select (#3846)
* fix(sidebar): cmd+click opens in new tab, shift+click for range select * comment cleanup * fix(sidebar): drop stale metaKey param from workflow and task selection hooks
1 parent ddb4427 commit c04f36d

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/workflow-item/workflow-item.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface WorkflowItemProps {
3535
active: boolean
3636
level: number
3737
dragDisabled?: boolean
38-
onWorkflowClick: (workflowId: string, shiftKey: boolean, metaKey: boolean) => void
38+
onWorkflowClick: (workflowId: string, shiftKey: boolean) => void
3939
onDragStart?: () => void
4040
onDragEnd?: () => void
4141
}
@@ -368,13 +368,15 @@ export function WorkflowItem({
368368
return
369369
}
370370

371-
const isModifierClick = e.shiftKey || e.metaKey || e.ctrlKey
371+
if (e.metaKey || e.ctrlKey) {
372+
return
373+
}
372374

373-
if (isModifierClick) {
375+
if (e.shiftKey) {
374376
e.preventDefault()
375377
}
376378

377-
onWorkflowClick(workflow.id, e.shiftKey, e.metaKey || e.ctrlKey)
379+
onWorkflowClick(workflow.id, e.shiftKey)
378380
},
379381
[shouldPreventClickRef, workflow.id, onWorkflowClick, isEditing]
380382
)

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-task-selection.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@ interface UseTaskSelectionProps {
99
}
1010

1111
/**
12-
* Hook for managing task selection with support for single, range, and toggle selection.
13-
* Handles shift-click for range selection and cmd/ctrl-click for toggle.
12+
* Hook for managing task selection with support for single and range selection.
13+
* Handles shift-click for range selection.
14+
* cmd/ctrl+click is handled by the browser (opens in new tab) and never reaches this handler.
1415
* Uses the last selected task as the anchor point for range selections.
1516
* Selecting tasks clears workflow/folder selections and vice versa.
1617
*/
1718
export function useTaskSelection({ taskIds }: UseTaskSelectionProps) {
1819
const selectedTasks = useFolderStore((s) => s.selectedTasks)
1920

2021
const handleTaskClick = useCallback(
21-
(taskId: string, shiftKey: boolean, metaKey: boolean) => {
22+
(taskId: string, shiftKey: boolean) => {
2223
const {
2324
selectTaskOnly,
2425
selectTaskRange,
2526
toggleTaskSelection,
2627
lastSelectedTaskId: anchor,
2728
} = useFolderStore.getState()
28-
if (metaKey) {
29-
toggleTaskSelection(taskId)
30-
} else if (shiftKey && anchor && anchor !== taskId) {
29+
if (shiftKey && anchor && anchor !== taskId) {
3130
selectTaskRange(taskIds, anchor, taskId)
3231
} else if (shiftKey) {
3332
toggleTaskSelection(taskId)

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workflow-selection.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,15 @@ export function useWorkflowSelection({
6060
}, [workflowAncestorFolderIds])
6161

6262
/**
63-
* Handle workflow click with support for shift-click range selection and cmd/ctrl-click toggle.
63+
* Handle workflow click with support for shift-click range selection.
64+
* cmd/ctrl+click is handled by the browser (opens in new tab) and never reaches this handler.
6465
*
6566
* @param workflowId - ID of clicked workflow
6667
* @param shiftKey - Whether shift key was pressed
67-
* @param metaKey - Whether cmd (Mac) or ctrl (Windows) key was pressed
6868
*/
6969
const handleWorkflowClick = useCallback(
70-
(workflowId: string, shiftKey: boolean, metaKey: boolean) => {
71-
if (metaKey) {
72-
toggleWorkflowSelection(workflowId)
73-
deselectConflictingFolders()
74-
} else if (shiftKey && activeWorkflowId && activeWorkflowId !== workflowId) {
70+
(workflowId: string, shiftKey: boolean) => {
71+
if (shiftKey && activeWorkflowId && activeWorkflowId !== workflowId) {
7572
selectRange(workflowIds, activeWorkflowId, workflowId)
7673
deselectConflictingFolders()
7774
} else if (shiftKey) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const SidebarTaskItem = memo(function SidebarTaskItem({
151151
isUnread: boolean
152152
isMenuOpen: boolean
153153
showCollapsedTooltips: boolean
154-
onMultiSelectClick: (taskId: string, shiftKey: boolean, metaKey: boolean) => void
154+
onMultiSelectClick: (taskId: string, shiftKey: boolean) => void
155155
onContextMenu: (e: React.MouseEvent, taskId: string) => void
156156
onMorePointerDown: () => void
157157
onMoreClick: (e: React.MouseEvent<HTMLButtonElement>, taskId: string) => void
@@ -167,9 +167,10 @@ const SidebarTaskItem = memo(function SidebarTaskItem({
167167
)}
168168
onClick={(e) => {
169169
if (task.id === 'new') return
170-
if (e.shiftKey || e.metaKey || e.ctrlKey) {
170+
if (e.metaKey || e.ctrlKey) return
171+
if (e.shiftKey) {
171172
e.preventDefault()
172-
onMultiSelectClick(task.id, e.shiftKey, e.metaKey || e.ctrlKey)
173+
onMultiSelectClick(task.id, true)
173174
} else {
174175
useFolderStore.setState({
175176
selectedTasks: new Set<string>(),
@@ -1058,8 +1059,6 @@ export const Sidebar = memo(function Sidebar() {
10581059
[handleCreateWorkflow]
10591060
)
10601061

1061-
const noop = useCallback(() => {}, [])
1062-
10631062
const handleExpandSidebar = useCallback(
10641063
(e: React.MouseEvent) => {
10651064
e.preventDefault()

0 commit comments

Comments
 (0)