add reproduction of the bug
This commit is contained in:
@@ -62,6 +62,7 @@ import MovingHandles from '../examples/MovingHandles';
|
|||||||
import DetachedHandle from '../examples/DetachedHandle';
|
import DetachedHandle from '../examples/DetachedHandle';
|
||||||
import ZIndexMode from '../examples/ZIndexMode';
|
import ZIndexMode from '../examples/ZIndexMode';
|
||||||
import Middlewares from '../examples/Middlewares';
|
import Middlewares from '../examples/Middlewares';
|
||||||
|
import NodeSelectionBug from '../examples/NodeSelectionBug';
|
||||||
|
|
||||||
export interface IRoute {
|
export interface IRoute {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -390,6 +391,11 @@ const routes: IRoute[] = [
|
|||||||
path: 'z-index-mode',
|
path: 'z-index-mode',
|
||||||
component: ZIndexMode,
|
component: ZIndexMode,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Node Selection Bug',
|
||||||
|
path: 'node-selection-bug',
|
||||||
|
component: NodeSelectionBug,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
|
|||||||
41
examples/react/src/examples/NodeSelectionBug/index.tsx
Normal file
41
examples/react/src/examples/NodeSelectionBug/index.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Node, ReactFlow, useNodesState } from '@xyflow/react';
|
||||||
|
|
||||||
|
import '@xyflow/react/dist/style.css';
|
||||||
|
import { useRef } from 'react';
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const [nodes, setNodes, onNodesChange] = useNodesState<Node>([
|
||||||
|
{
|
||||||
|
id: '0',
|
||||||
|
position: { x: 0, y: 0 },
|
||||||
|
data: { label: 'Rectangle Select Me First' },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const id = useRef(0);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
setNodes((nodes) => [
|
||||||
|
...nodes.map((node) => ({ ...node, selected: false })),
|
||||||
|
{
|
||||||
|
id: (++id.current).toString(),
|
||||||
|
position: { x: -100, y: 100 * Math.floor((id.current + 1) / 2) },
|
||||||
|
data: { label: `Button Node ${id.current}` },
|
||||||
|
selected: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: (++id.current).toString(),
|
||||||
|
position: { x: 100, y: (100 * id.current) / 2 },
|
||||||
|
data: { label: `Button Node ${id.current}` },
|
||||||
|
selected: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Click me to add nodes that are already selected.
|
||||||
|
</button>
|
||||||
|
<ReactFlow nodes={nodes} onNodesChange={onNodesChange} fitView></ReactFlow>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user