Add elevateNodesOnSelect prop, fix z-index not increased when selecting nodes

This commit is contained in:
peterkogo
2025-02-19 12:03:55 +01:00
parent e8a971e00a
commit bb28ef4846
3 changed files with 7 additions and 1 deletions

View File

@@ -64,6 +64,7 @@
colorModeSSR,
style,
defaultEdgeOptions,
elevateNodesOnSelect,
...divAttributes
} = $derived(rest);

View File

@@ -328,6 +328,11 @@ export type SvelteFlowProps = NodeEvents &
* If you have custom connection logic its preferred to use this callback over the isValidConnection prop on the handle component for performance reasons.
* @default (connection: Connection) => true
*/
/** Enabling this option will raise the z-index of nodes when they are selected.
* @default true
*/
elevateNodesOnSelect?: boolean;
isValidConnection?: IsValidConnection;
/** This event handler is called when the user begins to pan or zoom the viewport */
onMoveStart?: OnMoveStart;

View File

@@ -82,7 +82,7 @@ export const getInitialStore = (signals: StoreSignals) => {
adoptUserNodes(signals.nodes, this.nodeLookup, this.parentLookup, {
nodeExtent: this.nodeExtent,
nodeOrigin: this.nodeOrigin,
elevateNodesOnSelect: false,
elevateNodesOnSelect: signals.props.elevateNodesOnSelect ?? true,
checkEquality: true
});
return signals.nodes;