File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import {
3737 SIDEBAR_SECTION_GAP_CLASS ,
3838} from '@/app/workspace/[workspaceId]/w/components/sidebar/constants'
3939import { useSidebarResize } from '@/app/workspace/[workspaceId]/w/components/sidebar/hooks'
40+ import { isSidebarBackgroundClick } from '@/app/workspace/[workspaceId]/w/components/sidebar/utils'
4041import { useContextMenu } from '@/hooks/use-context-menu'
4142import { useFolderStore } from '@/stores/folders/store'
4243import { useSidebarStore } from '@/stores/sidebar/store'
@@ -146,9 +147,7 @@ export const OrganizationSidebar = memo(function OrganizationSidebar() {
146147 }
147148
148149 const handleSidebarClick = ( event : React . MouseEvent < HTMLElement > ) => {
149- if ( event . target instanceof Element && event . target . closest ( 'button, [role="button"], a' ) ) {
150- return
151- }
150+ if ( ! isSidebarBackgroundClick ( event ) ) return
152151 useFolderStore . getState ( ) . clearChatSelection ( )
153152 }
154153
Original file line number Diff line number Diff line change @@ -138,7 +138,13 @@ function IntentAwareChatNavigationLink({
138138 onTouchStart = { onTouchStart }
139139 onClick = { ( event ) => {
140140 onClick ?.( event )
141- if ( ! event . defaultPrevented && ! event . metaKey && ! event . ctrlKey && onSelectChat ) {
141+ if (
142+ ! event . defaultPrevented &&
143+ ! event . metaKey &&
144+ ! event . ctrlKey &&
145+ ! event . altKey &&
146+ onSelectChat
147+ ) {
142148 if ( event . shiftKey ) event . preventDefault ( )
143149 onSelectChat ( chatId , event . shiftKey )
144150 }
Original file line number Diff line number Diff line change @@ -115,6 +115,7 @@ import {
115115 compareByOrder ,
116116 createSidebarDragGhost ,
117117 groupWorkflowsByFolder ,
118+ isSidebarBackgroundClick ,
118119} from '@/app/workspace/[workspaceId]/w/components/sidebar/utils'
119120import { useImportWorkflow } from '@/app/workspace/[workspaceId]/w/hooks'
120121import { useCustomBlockOverlayVersion } from '@/blocks/custom/client-overlay'
@@ -1101,10 +1102,7 @@ export const Sidebar = memo(function Sidebar({ organizationHref }: SidebarProps)
11011102 )
11021103
11031104 const handleSidebarClick = ( e : React . MouseEvent < HTMLElement > ) => {
1104- const target = e . target as HTMLElement
1105- if ( target . tagName === 'BUTTON' || target . closest ( 'button, [role="button"], a' ) ) {
1106- return
1107- }
1105+ if ( ! isSidebarBackgroundClick ( e ) ) return
11081106 const { selectOnly, clearAllSelection } = useFolderStore . getState ( )
11091107 workflowId ? selectOnly ( workflowId ) : clearAllSelection ( )
11101108 }
Original file line number Diff line number Diff line change 1+ import type { MouseEvent } from 'react'
12import type { MothershipResource } from '@/lib/mothership/resource-types'
23import { getFolderMap } from '@/hooks/queries/utils/folder-cache'
34import { getWorkflows } from '@/hooks/queries/utils/workflow-cache'
45import type { FolderTreeNode } from '@/stores/folders/types'
56import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
67
8+ /** Distinguishes sidebar background clicks from controls and portaled overlays. */
9+ export function isSidebarBackgroundClick ( event : MouseEvent < HTMLElement > ) : boolean {
10+ return (
11+ event . target instanceof Element &&
12+ event . currentTarget . contains ( event . target ) &&
13+ ! event . target . closest ( 'button, [role="button"], a' )
14+ )
15+ }
16+
717/**
818 * Builds a `MothershipResource` array from a sidebar drag selection so it can
919 * be set as `application/x-sim-resources` drag data and dropped into the chat.
You can’t perform that action at this time.
0 commit comments