Skip to content

Commit da38b07

Browse files
committed
fix(mobile): preserve note search and canvas connections
1 parent 00388ab commit da38b07

4 files changed

Lines changed: 42 additions & 13 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/search-replace/workflow-search-replace.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ function WorkflowSearchReplacePanel({ focusRef }: WorkflowSearchReplacePanelProp
323323
if (!isFloatingLayout()) {
324324
useChatStore.getState().setIsChatOpen(false)
325325
useVariablesModalStore.getState().setIsOpen(false)
326+
usePanelStore.getState().setIsMobilePanelOpen(match.blockType !== 'note')
326327
}
327328
usePanelEditorStore.getState().setCurrentBlockId(match.blockId)
328-
usePanelStore.getState().setIsMobilePanelOpen(true)
329329
usePanelEditorSearchStore.getState().setActiveSearchTarget({
330330
...createActiveSearchTarget(match, query),
331331
})

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4376,6 +4376,33 @@ const WorkflowContent = React.memo(
43764376

43774377
const position = getAbsolutePosition(mountedNode)
43784378
const { width: nodeWidth, height: nodeHeight } = getFocusDimensions(mountedNode)
4379+
if (isMobile && mountedNode.type === 'noteBlock') {
4380+
const isExpanded = Boolean(
4381+
canvasContainerRef.current?.querySelector(
4382+
`[data-id="${CSS.escape(mountedNode.id)}"] [data-note-expanded]`
4383+
)
4384+
)
4385+
const width = isExpanded ? BLOCK_DIMENSIONS.NOTE_EXPANDED_WIDTH : nodeWidth
4386+
const height = isExpanded ? BLOCK_DIMENSIONS.NOTE_EXPANDED_HEIGHT : nodeHeight
4387+
fitViewToBounds({
4388+
nodes: [
4389+
{
4390+
...mountedNode,
4391+
position: {
4392+
x: position.x + (nodeWidth - width) / 2,
4393+
y: position.y + (nodeHeight - height) / 2,
4394+
},
4395+
measured: { width, height },
4396+
},
4397+
],
4398+
padding: SUBFLOW_FOCUS_PADDING,
4399+
maxZoom: 1,
4400+
minZoom: 0.1,
4401+
duration: durationMs,
4402+
})
4403+
onFocusStart?.()
4404+
return
4405+
}
43794406
const currentZoom = reactFlowInstance.getViewport().zoom
43804407
const targetZoom = Math.max(currentZoom, 1)
43814408
reactFlowInstance.setCenter(position.x + nodeWidth / 2, position.y + nodeHeight / 2, {
@@ -4425,7 +4452,7 @@ const WorkflowContent = React.memo(
44254452

44264453
waitForSettledCanvas()
44274454
},
4428-
[fitViewToBounds, getNodeAbsolutePosition, getNodes, reactFlowInstance]
4455+
[fitViewToBounds, getNodeAbsolutePosition, getNodes, isMobile, reactFlowInstance]
44294456
)
44304457

44314458
/**
@@ -4785,7 +4812,7 @@ const WorkflowContent = React.memo(
47854812
*/
47864813
const nodesForRender = useMemo(() => {
47874814
const elevatedNodes = sortNodesParentsFirst(displayNodes).map((node) => {
4788-
const renderedNode = isMobile ? { ...node, draggable: false, connectable: false } : node
4815+
const renderedNode = isMobile ? { ...node, draggable: false } : node
47894816
if (node.type === 'subflowNode') return renderedNode
47904817
const target = getBlockZIndex(node.zIndex ?? BLOCK_Z_BASE, {
47914818
isSelected: node.selected,
@@ -5168,7 +5195,7 @@ const WorkflowContent = React.memo(
51685195
panOnDrag={embedded || isMobile ? true : selectionProps.panOnDrag}
51695196
selectionKeyCode={embedded ? null : selectionProps.selectionKeyCode}
51705197
multiSelectionKeyCode={embedded ? null : ['Meta', 'Control', 'Shift']}
5171-
nodesConnectable={!embedded && !isMobile && effectivePermissions.canEdit}
5198+
nodesConnectable={!embedded && effectivePermissions.canEdit}
51725199
connectOnClick={false}
51735200
nodesDraggable={!embedded && !isMobile && effectivePermissions.canEdit}
51745201
draggable={false}

‎packages/workflow-renderer/src/subflow/subflow-node-view.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ const getCursorHandleSize = (side: WorkflowBorderCursorHandle['edgeSide']) =>
111111
/** Invisible React Flow handles aligned with the painted connection knobs. */
112112
const getHandleClasses = (position: 'left' | 'right') => {
113113
const baseClasses =
114-
'z-20! h-[38px]! w-[14px]! cursor-crosshair! rounded-none! border-none! bg-transparent! opacity-0!'
114+
"z-20! h-[38px]! w-[14px]! cursor-crosshair! rounded-none! border-none! bg-transparent! opacity-0! pointer-coarse:before:absolute pointer-coarse:before:inset-y-0 pointer-coarse:before:content-['']"
115115

116116
const positionClasses = {
117-
left: 'left-[-7px]!',
118-
right: 'right-[-7px]!',
117+
left: 'left-[-7px]! pointer-coarse:before:right-0 pointer-coarse:before:left-[-30px]',
118+
right: 'right-[-7px]! pointer-coarse:before:right-[-30px] pointer-coarse:before:left-0',
119119
}
120120

121121
return cn(baseClasses, positionClasses[position])

‎packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ const clampTabLength = (length: number) =>
133133
*/
134134
const getInvisibleHandleClasses = (side: 'left' | 'right' | 'top' | 'bottom') => {
135135
const offsetClasses = {
136-
right: 'right-[-7px]!',
137-
left: 'left-[-7px]!',
138-
top: 'top-[-7px]!',
139-
bottom: 'bottom-[-7px]!',
136+
right:
137+
'right-[-7px]! pointer-coarse:before:inset-y-0 pointer-coarse:before:right-[-30px] pointer-coarse:before:left-0',
138+
left: 'left-[-7px]! pointer-coarse:before:inset-y-0 pointer-coarse:before:right-0 pointer-coarse:before:left-[-30px]',
139+
top: 'top-[-7px]! pointer-coarse:before:inset-x-0 pointer-coarse:before:top-[-30px] pointer-coarse:before:bottom-0',
140+
bottom:
141+
'bottom-[-7px]! pointer-coarse:before:inset-x-0 pointer-coarse:before:top-0 pointer-coarse:before:bottom-[-30px]',
140142
} as const
141143
return cn(
142-
'z-20! cursor-crosshair! rounded-none! border-none! bg-transparent! opacity-0!',
144+
"z-20! cursor-crosshair! rounded-none! border-none! bg-transparent! opacity-0! pointer-coarse:before:absolute pointer-coarse:before:content-['']",
143145
offsetClasses[side]
144146
)
145147
}
@@ -1075,7 +1077,7 @@ export function WorkflowBlockView({
10751077
type='source'
10761078
position={ERROR_SOURCE_HANDLE_POSITION}
10771079
id='error'
1078-
className='z-20! cursor-crosshair! rounded-none! border-none! bg-transparent! opacity-0!'
1080+
className={getInvisibleHandleClasses('bottom')}
10791081
style={getErrorSourceHandleStyle()}
10801082
data-nodeid={id}
10811083
data-handleid='error'

0 commit comments

Comments
 (0)