You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "Kusuma04-dev (via GitHub)" <gi...@apache.org> on 2026/08/20 06:04:58 UTC
[PR] Kie-issue#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Kusuma04-dev opened a new pull request, #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720
closes https://github.com/apache/incubator-kie-issues/issues/1495,
Upgraded ReactFlow from v11 to v12.
**Package updates**
Updated @xyflow/react to ^12.0.0 across all three packages (xyflow-react-kie-diagram, dmn-editor, bpmn-editor).
**API renames**
onEdgeUpdate → onReconnect
onEdgeUpdateStart → onReconnectStart
onEdgeUpdateEnd → onReconnectEnd
nodeInternals (Map) → nodeLookup (Map)
node.positionAbsolute → node.internals.positionAbsolute
node.width / node.height → node.measured.width / node.measured.height
Connection state reads changed from connectionNodeId / connectionHandleType → s.connection.fromHandle?.nodeId / s.connection.fromHandle?.type
**Connection line fix**
Removed the incorrect ?? fromNode.position.x fallback in the shared ConnectionLine. In v12 fromNode.internals.positionAbsolute is always present; falling back to the relative position field produces wrong connection line origins.
**Palette drag fix**
The synthetic NodePositionChange emitted during palette drag-over was setting the non-existent v12 field positionAbsolute. Changed to set position, which is the correct field in v12's NodePositionChange type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "tiagobento (via GitHub)" <gi...@apache.org>.
tiagobento commented on PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#issuecomment-5432864113
Strange that the PR checks took almost 5h. There must be something wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3842948336
##########
packages/dmn-editor/src/clipboard/Clipboard.ts:
##########
Review Comment:
Castings.
##########
packages/bpmn-editor/src/diagram/BpmnDiagramCommands.tsx:
##########
Review Comment:
Castings.
##########
packages/bpmn-editor/src/clipboard/Clipboard.ts:
##########
Review Comment:
Castings.
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
Review Comment:
Castings.
##########
packages/xyflow-react-kie-diagram/src/snapgrid/BorderSnapping.ts:
##########
Review Comment:
Castings.
##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
Review Comment:
Castings.
##########
packages/dmn-editor/src/diagram/DiagramCommands.tsx:
##########
Review Comment:
Castings.
##########
packages/xyflow-react-kie-diagram/src/edges/ConnectionLine.tsx:
##########
Review Comment:
Castings
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#issuecomment-5438541711
Yes @ljmotta , I am running in local. I will update once fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3842523318
##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
@@ -1762,15 +1802,34 @@ export function SetConnectionToReactFlowStore(props: {}) {
const rfStoreApi = RF.useStoreApi();
useEffect(() => {
rfStoreApi.setState({
- connectionHandleId: ongoingConnection?.handleId,
- connectionHandleType: ongoingConnection?.handleType,
- connectionNodeId: ongoingConnection?.nodeId,
+ connection: {
+ fromHandle: ongoingConnection
+ ? {
+ nodeId: ongoingConnection.nodeId ?? null,
+ id: ongoingConnection.handleId ?? null,
+ type: ongoingConnection.handleType ?? null,
+ }
+ : undefined,
+ toHandle: null,
+ } as any,
Review Comment:
Addressed these review comments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3913119916
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -527,8 +562,11 @@ export function XyFlowReactKieDiagram<
state.xyFlowReactKieDiagram.newNodeProjection!;
let foundContainer = false;
- for (const potentialContainer of reactFlowInstance?.getNodes().reverse() ??
- [] /* Respect the nodes z-index */) {
+ // Use xyFlowStoreApi for synchronous access; nodeLookup stores InternalNode<Node> so we cast
+ // through unknown to Node<NData, N> (safe since NData satisfies Record<string, unknown>).
+ for (const potentialContainer of (
+ Array.from(xyFlowStoreApi.getState().nodeLookup.values()) as unknown as RF.Node<NData, N>[]
Review Comment:
I haven't pushed the changes yet for this @ljmotta , i am fixing in local and running e2e tests locally. I will update once all changes are done. Please hold review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "Kusuma04-dev (via GitHub)" <gi...@apache.org>.
Kusuma04-dev commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3845225085
##########
packages/xyflow-react-kie-diagram/src/snapgrid/BorderSnapping.ts:
##########
Review Comment:
Thanks @ljmotta for the review, I have reviewed all the files and updated! I will cross check again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3841505678
##########
packages/dmn-editor/src/diagram/Diagram.tsx:
##########
@@ -1762,15 +1802,34 @@ export function SetConnectionToReactFlowStore(props: {}) {
const rfStoreApi = RF.useStoreApi();
useEffect(() => {
rfStoreApi.setState({
- connectionHandleId: ongoingConnection?.handleId,
- connectionHandleType: ongoingConnection?.handleType,
- connectionNodeId: ongoingConnection?.nodeId,
+ connection: {
+ fromHandle: ongoingConnection
+ ? {
+ nodeId: ongoingConnection.nodeId ?? null,
+ id: ongoingConnection.handleId ?? null,
+ type: ongoingConnection.handleType ?? null,
+ }
+ : undefined,
+ toHandle: null,
+ } as any,
Review Comment:
This replaces React Flow's complete `ConnectionState` with a two-field object. In v12, the connection-line wrapper requires `connection.inProgress` and reads the remaining geometry fields; after this effect runs following `onConnectStart`, `inProgress` becomes `undefined`, so the dragged connection line disappears until React Flow writes the state again. Preserve/update the full connection state (and cancel it through `cancelConnection`), and handle click-to-connect through `connectionClickStartHandle` or consumer fallbacks rather than casting a partial object.
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -1035,83 +1095,99 @@ export function XyFlowReactKieDiagram<
);
return (
- <>
- <I18nDictionariesProvider
- defaults={kieDiagramI18nDefaults}
- dictionaries={kieDiagramI18nDictionaries}
- initialLocale={navigator.language}
- ctx={KieDiagramI18nContext}
- >
- <WaypointActionsContextProvider value={waypointActionsContextValue}>
- <RF.ReactFlow
- connectionMode={RF.ConnectionMode.Loose} // Allow target handles to be used as source. This is very important for allowing the positional handles to be updated for the base of an edge.
- onKeyDownCapture={handleRfKeyDownCapture} // Override Reactflow's keyboard listeners.
- nodes={nodes}
- edges={edges}
- onNodesChange={onNodesChange}
- onEdgesChange={onEdgesChange}
- onEdgeUpdateStart={onEdgeUpdateStart}
- onEdgeUpdateEnd={onEdgeUpdateEnd}
- onEdgeUpdate={onEdgeUpdate}
- onlyRenderVisibleElements={true}
- zoomOnDoubleClick={false}
- elementsSelectable={true}
- panOnScroll={true}
- zoomOnScroll={false}
- preventScrolling={true}
- selectionOnDrag={true}
- panOnDrag={PAN_ON_DRAG}
- selectionMode={RF.SelectionMode.Full} // For selections happening inside Containment nodes it's better to leave it as "Full"
- isValidConnection={isValidConnection}
- connectionLineComponent={connectionLineComponent}
- onConnect={onConnect}
- onConnectStart={onConnectStart}
- onConnectEnd={onConnectEnd}
- // (begin)
- // 'Starting to drag' and 'dragging' should have the same behavior. Otherwise,
- // clicking a node and letting it go, without moving, won't work properly, and
- // Nodes will be removed from Containment Nodes.
- onNodeDragStart={onNodeDragStart}
- onNodeDrag={onNodeDrag}
- // (end)
- onNodeDragStop={onNodeDragStop}
- nodeTypes={nodeComponents}
- edgeTypes={edgeComponents}
- snapToGrid={true}
- snapGrid={xyFlowSnapGrid}
- defaultViewport={DEFAULT_VIEWPORT}
- fitView={false}
- fitViewOptions={FIT_VIEW_OPTIONS}
- attributionPosition={"bottom-right"}
- onInit={setReactFlowInstance}
- deleteKeyCode={DELETE_NODE_KEY_CODES}
- // (begin)
- // Used to make the Palette work by dropping nodes on the Reactflow Canvas
- onDrop={onDrop}
- onDragOver={onDragOver}
- // (end)
- >
- {children}
- <SelectionStatusLabel />
- {!isFirefox && <RF.Background />}
- <RF.Controls fitViewOptions={FIT_VIEW_OPTIONS} position={"bottom-right"} />
- <SetConnectionToReactFlowStore />
- </RF.ReactFlow>
- </WaypointActionsContextProvider>
- </I18nDictionariesProvider>
- </>
+ <I18nDictionariesProvider
+ defaults={kieDiagramI18nDefaults}
+ dictionaries={kieDiagramI18nDictionaries}
+ initialLocale={navigator.language}
+ ctx={KieDiagramI18nContext}
+ >
+ <WaypointActionsContextProvider value={waypointActionsContextValue}>
+ <RF.ReactFlow
+ connectionMode={RF.ConnectionMode.Loose} // Allow target handles to be used as source. This is very important for allowing the positional handles to be updated for the base of an edge.
+ onKeyDownCapture={handleRfKeyDownCapture} // Override Reactflow's keyboard listeners.
+ nodes={nodes}
+ edges={edges}
+ onNodesChange={onNodesChange}
+ onEdgesChange={onEdgesChange}
+ onReconnectStart={onReconnectStart}
+ onReconnectEnd={onReconnectEnd}
+ onReconnect={onReconnect}
+ onlyRenderVisibleElements={true}
+ zoomOnDoubleClick={false}
+ elementsSelectable={true}
+ panOnScroll={true}
+ zoomOnScroll={false}
+ preventScrolling={true}
+ selectionOnDrag={true}
+ panOnDrag={PAN_ON_DRAG}
+ selectionMode={RF.SelectionMode.Full} // For selections happening inside Containment nodes it's better to leave it as "Full"
+ isValidConnection={isValidConnection}
+ connectionLineComponent={connectionLineComponent}
+ onConnect={onConnect}
+ onConnectStart={onConnectStart}
+ onConnectEnd={onConnectEnd}
+ // (begin)
+ // 'Starting to drag' and 'dragging' should have the same behavior. Otherwise,
+ // clicking a node and letting it go, without moving, won't work properly, and
+ // Nodes will be removed from Containment Nodes.
+ onNodeDragStart={onNodeDragStart as RF.OnNodeDrag}
+ onNodeDrag={onNodeDrag as RF.OnNodeDrag}
+ // (end)
+ onNodeDragStop={onNodeDragStop as RF.OnNodeDrag}
+ nodeTypes={nodeComponents}
+ edgeTypes={edgeComponents}
+ snapToGrid={true}
+ snapGrid={xyFlowSnapGrid}
+ defaultViewport={DEFAULT_VIEWPORT}
+ fitView={false}
+ fitViewOptions={FIT_VIEW_OPTIONS}
+ attributionPosition={"bottom-right"}
+ onInit={setReactFlowInstance as RF.OnInit}
+ deleteKeyCode={DELETE_NODE_KEY_CODES}
+ // (begin)
+ // Used to make the Palette work by dropping nodes on the Reactflow Canvas
+ onDrop={onDrop}
+ onDragOver={onDragOver}
+ // (end)
+ >
+ {children}
+ <SelectionStatusLabel />
+ {!isFirefox && <RF.Background />}
+ <RF.Controls fitViewOptions={FIT_VIEW_OPTIONS} position={"bottom-right"} />
+ <SetConnectionToReactFlowStore />
+ <NodeLookupSync nodeLookupRef={nodeLookupRef} />
+ </RF.ReactFlow>
+ </WaypointActionsContextProvider>
+ </I18nDictionariesProvider>
);
}
+function NodeLookupSync(props: { nodeLookupRef: React.MutableRefObject<RF.ReactFlowState["nodeLookup"] | undefined> }) {
+ const xyFlowStoreApi = RF.useStoreApi();
+ // useLayoutEffect fires synchronously before paint, ensuring nodeLookupRef is populated
+ // before onNodesChange can read from it during the same render cycle.
+ useLayoutEffect(() => {
+ props.nodeLookupRef.current = xyFlowStoreApi.getState().nodeLookup;
+ });
+ return null;
+}
+
export function SetConnectionToReactFlowStore(props: {}) {
const ongoingConnection = useXyFlowReactKieDiagramStore((s) => s.xyFlowReactKieDiagram.ongoingConnection);
const xyFlowStoreApi = RF.useStoreApi();
useEffect(() => {
xyFlowStoreApi.setState({
- connectionHandleId: ongoingConnection?.handleId,
- connectionHandleType: ongoingConnection?.handleType,
- connectionNodeId: ongoingConnection?.nodeId,
+ connection: {
+ fromHandle: ongoingConnection
+ ? {
+ nodeId: ongoingConnection.nodeId ?? null,
+ id: ongoingConnection.handleId ?? null,
+ type: ongoingConnection.handleType ?? null,
+ }
+ : undefined,
+ toHandle: null,
+ } as any,
Review Comment:
This replaces React Flow's complete `ConnectionState` with a two-field object. In v12, the connection-line wrapper requires `connection.inProgress` and reads the remaining geometry fields; after this effect runs following `onConnectStart`, `inProgress` becomes `undefined`, so the dragged connection line disappears until React Flow writes the state again. Preserve/update the full connection state (and cancel it through `cancelConnection`), and handle click-to-connect through `connectionClickStartHandle` or consumer fallbacks rather than casting a partial object.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#issuecomment-5437718963
@Kusuma04-dev We have many E2E tests failling. I believe it is worth to run the suite locally, as it will be faster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3912792112
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -527,8 +562,11 @@ export function XyFlowReactKieDiagram<
state.xyFlowReactKieDiagram.newNodeProjection!;
let foundContainer = false;
- for (const potentialContainer of reactFlowInstance?.getNodes().reverse() ??
- [] /* Respect the nodes z-index */) {
+ // Use xyFlowStoreApi for synchronous access; nodeLookup stores InternalNode<Node> so we cast
+ // through unknown to Node<NData, N> (safe since NData satisfies Record<string, unknown>).
+ for (const potentialContainer of (
+ Array.from(xyFlowStoreApi.getState().nodeLookup.values()) as unknown as RF.Node<NData, N>[]
Review Comment:
@Kusuma04-dev It is still being cast to `unkown`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] kie-issues#1495: Upgrade ReactFlow from v11 to v12 on kie-tools [incubator-kie-tools]
Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on code in PR #3720:
URL: https://github.com/apache/incubator-kie-tools/pull/3720#discussion_r3870854314
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -632,21 +670,22 @@ export function XyFlowReactKieDiagram<
dropTarget,
{
...(node ?? state.xyFlowReactKieDiagram.newNodeProjection).data.shape["dc:Bounds"],
- "@_x": change.positionAbsolute.x,
- "@_y": change.positionAbsolute.y,
+ "@_x": positionAbsolute.x,
+ "@_y": positionAbsolute.y,
},
- (node ?? state.xyFlowReactKieDiagram.newNodeProjection).type!,
+ (node ?? state.xyFlowReactKieDiagram.newNodeProjection).type! as N,
Review Comment:
Casting to `N`
##########
packages/bpmn-editor/src/clipboard/Clipboard.ts:
##########
@@ -170,7 +175,7 @@ export function buildClipboardFromDiagram(xyFlowState: RF.ReactFlowState, bpmnEd
}
);
- clipboard.edges = xyFlowState.edges.flatMap((edge: RF.Edge<BpmnDiagramEdgeData>) => {
+ clipboard.edges = (xyFlowState.edges as RF.Edge<BpmnDiagramEdgeData>[]).flatMap((edge) => {
Review Comment:
`edges` must have the correct type.
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -920,7 +965,10 @@ export function XyFlowReactKieDiagram<
nodeIdBeingDraggedRef.current = newNodeId;
});
- onNodeDragStop(undefined as any, { dragging: true } as any, []);
+ // Palette drops count as "moved"; invoke onNodeDragStop with a synthetic event to trigger parenting logic
+ // (callback only reads nodeIdBeingDraggedRef, not `node`).
+ nodeActuallyMovedRef.current = true;
+ onNodeDragStop(new MouseEvent("mouseup"), {} as RF.Node<NData, N>, []);
Review Comment:
👍 I don't think we can avoid this one.
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -751,7 +794,7 @@ export function XyFlowReactKieDiagram<
// Un-parent
if (nodeBeingDragged.data.parentXyFlowNode) {
const p = state.computed(state).getDiagramData().nodesById.get(nodeBeingDragged.data.parentXyFlowNode.id);
- if (p?.type && containmentMap.get(p.type)) {
+ if (p?.type && (containmentMap as Map<string, unknown>).has(p.type)) {
Review Comment:
Casting to `Map<string, unknown>`
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -1035,85 +1083,103 @@ export function XyFlowReactKieDiagram<
);
return (
- <>
- <I18nDictionariesProvider
- defaults={kieDiagramI18nDefaults}
- dictionaries={kieDiagramI18nDictionaries}
- initialLocale={navigator.language}
- ctx={KieDiagramI18nContext}
- >
- <WaypointActionsContextProvider value={waypointActionsContextValue}>
- <RF.ReactFlow
- connectionMode={RF.ConnectionMode.Loose} // Allow target handles to be used as source. This is very important for allowing the positional handles to be updated for the base of an edge.
- onKeyDownCapture={handleRfKeyDownCapture} // Override Reactflow's keyboard listeners.
- nodes={nodes}
- edges={edges}
- onNodesChange={onNodesChange}
- onEdgesChange={onEdgesChange}
- onEdgeUpdateStart={onEdgeUpdateStart}
- onEdgeUpdateEnd={onEdgeUpdateEnd}
- onEdgeUpdate={onEdgeUpdate}
- onlyRenderVisibleElements={true}
- zoomOnDoubleClick={false}
- elementsSelectable={true}
- panOnScroll={true}
- zoomOnScroll={false}
- preventScrolling={true}
- selectionOnDrag={true}
- panOnDrag={PAN_ON_DRAG}
- selectionMode={RF.SelectionMode.Full} // For selections happening inside Containment nodes it's better to leave it as "Full"
- isValidConnection={isValidConnection}
- connectionLineComponent={connectionLineComponent}
- onConnect={onConnect}
- onConnectStart={onConnectStart}
- onConnectEnd={onConnectEnd}
- // (begin)
- // 'Starting to drag' and 'dragging' should have the same behavior. Otherwise,
- // clicking a node and letting it go, without moving, won't work properly, and
- // Nodes will be removed from Containment Nodes.
- onNodeDragStart={onNodeDragStart}
- onNodeDrag={onNodeDrag}
- // (end)
- onNodeDragStop={onNodeDragStop}
- nodeTypes={nodeComponents}
- edgeTypes={edgeComponents}
- snapToGrid={true}
- snapGrid={xyFlowSnapGrid}
- defaultViewport={DEFAULT_VIEWPORT}
- fitView={false}
- fitViewOptions={FIT_VIEW_OPTIONS}
- attributionPosition={"bottom-right"}
- onInit={setReactFlowInstance}
- deleteKeyCode={DELETE_NODE_KEY_CODES}
- // (begin)
- // Used to make the Palette work by dropping nodes on the Reactflow Canvas
- onDrop={onDrop}
- onDragOver={onDragOver}
- // (end)
- >
- {children}
- <SelectionStatusLabel />
- {!isFirefox && <RF.Background />}
- <RF.Controls fitViewOptions={FIT_VIEW_OPTIONS} position={"bottom-right"} />
- <SetConnectionToReactFlowStore />
- </RF.ReactFlow>
- </WaypointActionsContextProvider>
- </I18nDictionariesProvider>
- </>
+ <I18nDictionariesProvider
+ defaults={kieDiagramI18nDefaults}
+ dictionaries={kieDiagramI18nDictionaries}
+ initialLocale={navigator.language}
+ ctx={KieDiagramI18nContext}
+ >
+ <WaypointActionsContextProvider value={waypointActionsContextValue}>
+ <RF.ReactFlow
+ connectionMode={RF.ConnectionMode.Loose} // Allow target handles to be used as source. This is very important for allowing the positional handles to be updated for the base of an edge.
+ onKeyDownCapture={handleRfKeyDownCapture} // Override Reactflow's keyboard listeners.
+ nodes={nodes}
+ edges={edges}
+ onNodesChange={onNodesChange}
+ onEdgesChange={onEdgesChange}
+ onReconnectStart={onReconnectStart}
+ onReconnectEnd={onReconnectEnd}
+ onReconnect={onReconnect}
+ onlyRenderVisibleElements={true}
+ zoomOnDoubleClick={false}
+ elementsSelectable={true}
+ panOnScroll={true}
+ zoomOnScroll={false}
+ preventScrolling={true}
+ selectionOnDrag={true}
+ panOnDrag={PAN_ON_DRAG}
+ selectionMode={RF.SelectionMode.Full} // For selections happening inside Containment nodes it's better to leave it as "Full"
+ isValidConnection={isValidConnection}
+ connectionLineComponent={connectionLineComponent}
+ onConnect={onConnect}
+ onConnectStart={onConnectStart}
+ onConnectEnd={onConnectEnd}
+ // (begin)
+ // 'Starting to drag' and 'dragging' should have the same behavior. Otherwise,
+ // clicking a node and letting it go, without moving, won't work properly, and
+ // Nodes will be removed from Containment Nodes.
+ onNodeDragStart={onNodeDragStart}
+ onNodeDrag={onNodeDrag}
+ // (end)
+ onNodeDragStop={onNodeDragStop}
+ nodeTypes={nodeComponents}
+ edgeTypes={edgeComponents}
+ snapToGrid={true}
+ snapGrid={xyFlowSnapGrid}
+ defaultViewport={DEFAULT_VIEWPORT}
+ fitView={false}
+ fitViewOptions={FIT_VIEW_OPTIONS}
+ attributionPosition={"bottom-right"}
+ onInit={(instance) =>
+ setReactFlowInstance(instance as RF.ReactFlowInstance<RF.Node<NData, N>, RF.Edge<EData>>)
+ }
Review Comment:
Can't we type `intance` instead?
##########
packages/xyflow-react-kie-diagram/src/diagram/XyFlowReactKieDiagram.tsx:
##########
@@ -527,8 +562,11 @@ export function XyFlowReactKieDiagram<
state.xyFlowReactKieDiagram.newNodeProjection!;
let foundContainer = false;
- for (const potentialContainer of reactFlowInstance?.getNodes().reverse() ??
- [] /* Respect the nodes z-index */) {
+ // Use xyFlowStoreApi for synchronous access; nodeLookup stores InternalNode<Node> so we cast
+ // through unknown to Node<NData, N> (safe since NData satisfies Record<string, unknown>).
+ for (const potentialContainer of (
+ Array.from(xyFlowStoreApi.getState().nodeLookup.values()) as unknown as RF.Node<NData, N>[]
Review Comment:
Casting to `unknown`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org