File tree 2 files changed +16
-1
lines changed 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,14 @@ export const useBaseGraph = (
265
265
266
266
updateAggregator . push ( liftHoveredNodeToTop ) ;
267
267
268
+ /**
269
+ * Sets the current hovered node (e.g. when adding a new node)
270
+ * @param node - the node to set as hovered
271
+ */
272
+ const setCurrHoveredNode = ( node : GNode | undefined ) => {
273
+ currHoveredNode = node ;
274
+ } ;
275
+
268
276
/**
269
277
* load a graph state into the graph
270
278
* @param graphState - the graph state to load (nodes and edges)
@@ -354,6 +362,7 @@ export const useBaseGraph = (
354
362
* a mapping of all graph events to a set of their callback functions
355
363
*/
356
364
eventBus,
365
+ setCurrHoveredNode,
357
366
subscribe,
358
367
unsubscribe,
359
368
emit,
Original file line number Diff line number Diff line change @@ -13,7 +13,13 @@ export const useInteractive = (graph: BaseGraph) => {
13
13
14
14
const nodeAdded = graph . addNode ( coords ) ;
15
15
if ( ! nodeAdded ) return ;
16
- setTimeout ( ( ) => graph . updateGraphAtMousePosition ( event ) , 10 ) ;
16
+ setTimeout ( ( ) => {
17
+ graph . updateGraphAtMousePosition ( event ) ;
18
+
19
+ // The cursor is now hovering this new node
20
+ graph . setCurrHoveredNode ( nodeAdded satisfies GNode ) ;
21
+ graph . emit ( 'onNodeHoverChange' , nodeAdded satisfies GNode , undefined ) ;
22
+ } , 10 ) ;
17
23
} ;
18
24
19
25
const doesEdgeConformToRules = ( fromNode : GNode , toNode : GNode ) => {
You can’t perform that action at this time.
0 commit comments