feat: The Big One UI #47
@@ -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]);
|
||||
});
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user