Comments (4)
@bcakmakoglu Sorry about the late reply. So my issue is that all three of the options you provided essentially require specific scenarios. Something like isFocusable is clear and applies in every case, and matches with accessibility. However, something I'd expect to be extremely similar to isFocusable for a click action is anything but simple.
For (2), this is doable, but when you're in a tailwind environment, this now forces a css file to be defined, since there's no tailwind option to override it.
For (1) and (3), I can see the selectable option in the docs and this file
, but it doesn't seem not appear to actually remove the styling for an edge, so you still get the pointer showing up. I'm using a custom edge and you can see it still shows all the clickable aspects. Here's parts of the relevant code and a screen grab:export type TreeEdge = Edge<{
start: { x: number, y: number }
center: { x: number, y: number },
end: { x: number, y: number };
}>;
function makeEdge(left: string, right: string): TreeEdge {
return {
id: `Edge-${left || 'null'}-${right || 'null'}`,
type: CanvasEdgeTypes.CustomEdge,
source: left,
target: right,
data: {
start: { x: 0, y: 0 }, // calculated later
center: { x: 0, y: 0 }, // calculated later
end: { x: 0, y: 0 }, // calculated later
},
// animated: true, // turned this off because it was taking a ton of GPU processing
focusable: false,
selectable: false, // there's a TS error here - it isn't defined
};
}
...
const edgeTypes = useMemo(() => ({
[CanvasEdgeTypes.CustomEdge]: CustomEdge,
}), []);
<ReactFlow
nodeTypes={nodeTypes}
edgeTypes={edgeTypes}
nodes={nodes}
edges={edges}
...
export function CustomEdge(edge: TreeEdge) {
const {
id,
data,
} = edge;
if (!data) return null;
const { start, end, center } = data;
const isCurved = center.x !== -1 && center.y !== -1;
let edgePath;
if (isCurved) {
([edgePath] = getSmoothStepPath({
sourceX: start.x,
sourceY: start.y,
centerX: center.x,
centerY: center.y,
targetX: end.x,
targetY: end.y,
sourcePosition: Position.Right, // must match handles
targetPosition: Position.Left, // must match handles
borderRadius: 4,
offset: 0,
}));
} else {
([edgePath] = getStraightPath({
sourceX: start.x,
sourceY: start.y,
targetX: end.x,
targetY: end.y,
}));
}
return (
<BaseEdge id={id} path={edgePath} />
);
}
Also, seems like there is a typing issue somewhere too. I can see that selectable prop defined here:
xyflow/packages/system/src/types/edges.ts
Line 26 in 82f40b4
type DefaultEdge<T = any> = {
id: string;
type?: string;
source: string;
target: string;
sourceHandle?: string | null;
targetHandle?: string | null;
style?: CSSProperties;
animated?: boolean;
hidden?: boolean;
deletable?: boolean;
data?: T;
className?: string;
sourceNode?: Node;
targetNode?: Node;
selected?: boolean;
markerStart?: EdgeMarkerType;
markerEnd?: EdgeMarkerType;
zIndex?: number;
ariaLabel?: string;
interactionWidth?: number;
focusable?: boolean;
updatable?: EdgeUpdatable;
} & EdgeLabelOptions;
export type Edge<T = any> = DefaultEdge<T> | SmoothStepEdgeType<T> | BezierEdgeType<T>;
from xyflow.
Sorry for the confusion. edge. selectable
is a new v12 feature. I would go with the CSS solution for v11.
from xyflow.
Since there are already ways to go about this, I'm not sure if introducing another prop is really that beneficial (we already have quite a number of props available already).
- As you said, you can solve this with a custom edge
- You can use CSS to disable pointer events on edges
.react-flow__edges { pointer-events: none }
- You can set
edge.selectable
tofalse
which basically disables running any action on click (or usedefaultEdgeOptions
to set it tofalse
for just all edges by default)
What specific benefit would this new prop have from your point of view? If it's really just about "disabling" the click (though if you don't have any listener bound for it, what exactly is the reason for "disabling" it?) I feel like there are easy enough options already.
from xyflow.
@moklick thanks for the clarification! Will definitely keep a watch on that v12 release!
from xyflow.
Related Issues (20)
- Testing creation of edge connections in v12 beta HOT 1
- getSmoothStepPath center position is ignored if it is zero HOT 1
- Show edge label renderer only on hover HOT 2
- Add connection snapping also for hover based snapping
- onNodeClick and onNodeDoubleClick both events are not working together HOT 2
- Svelte Flow: Align handle connecting logic with react HOT 2
- Svelte Flow: re-initialize nodes with nodes that are already in the store breaks flow HOT 1
- Updating parentNode property in Subflow causes positioning issues with node HOT 3
- [12.next10] strange node reorder after setNode HOT 11
- `ref` prop is missing HOT 1
- Safari: pane gets selected when user drags connection line HOT 1
- useNodesData: fix equality check for return value HOT 1
- Svelte Flow: make it possible to pass multiple keys for one action like deleting nodes/edges HOT 1
- useUpdateNodeInternals doesn't update handle positions during active connection HOT 6
- SvelteFlow on:selectionchange doesn't get called HOT 3
- RollupError: 'const' declarations must be initialized HOT 3
- Rotatable parent node HOT 5
- Resizing rotated node HOT 2
- Adding multiple Buttons in on the node and Multiple trees in same react flow canvas
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xyflow.