feat: made jumpToNode select the node after focussing the editor

ref: N25B-450
This commit is contained in:
JGerla
2026-01-20 10:22:08 +01:00
parent 5a9b78fdda
commit 487ee30923

View File

@@ -1,10 +1,11 @@
import {useReactFlow} from "@xyflow/react";
import {useReactFlow, useStoreApi} from "@xyflow/react";
import clsx from "clsx";
import {useEffect, useState} from "react";
import useFlowStore from "../VisProgStores.tsx";
import {
warningSummary,
type WarningSeverity, type EditorWarning
type WarningSeverity,
type EditorWarning, globalWarning
} from "./EditorWarnings.tsx";
import styles from "./WarningSidebar.module.css";
@@ -106,8 +107,11 @@ function WarningListItem(props: { warning: EditorWarning }) {
function useJumpToNode() {
const { getNode, setCenter } = useReactFlow();
const { addSelectedNodes } = useStoreApi().getState();
return (nodeId: string) => {
// user can't jump to global warning, so prevent further logic from running
if (nodeId === globalWarning) return;
const node = getNode(nodeId);
if (!node) return;
@@ -118,7 +122,10 @@ function useJumpToNode() {
position!.x + width / 2,
position!.y + height / 2,
{ zoom: 2, duration: 300 }
);
).then(() => {
// select the node
addSelectedNodes([nodeId]);
});
};
}