diff --git a/src/components/editor.tsx b/src/components/editor.tsx index 2498b17..75cdf9b 100644 --- a/src/components/editor.tsx +++ b/src/components/editor.tsx @@ -573,12 +573,14 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . } if (names.length === 0 && editor.searchingText) { const matrix = editor.graphMatrix; + const selectedId = editor.selectedId; onSearchChange({ ...filterOption, filterType: "content", filterStr: editor.searchingText, }); editor.graphMatrix = matrix; + selectNode(selectedId); restoreViewport(); } }; @@ -801,8 +803,6 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . const rename = (newPath: string) => { editor.path = newPath; - editor.size.width = 0; - editor.size.height = 0; }; const save = () => { @@ -878,13 +878,6 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . }, 200); }; - const destroyGraph = () => { - if (editor.graph) { - editor.graph.destroy(); - editor.graph = undefined!; - } - }; - const createGraph = (ref: React.MutableRefObject) => { editor.graph = new TreeGraph({ container: ref.current!, @@ -1237,14 +1230,15 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . return; } - if (editor.size.width !== editorSize.width || editor.size.height !== editorSize.height) { - destroyGraph(); - } - if (!editor.graph) { createGraph(graphRef); - editor.size.width = editorSize.width; - editor.size.height = editorSize.height; + } + + if ( + editor.graph.getWidth() !== editorSize.width || + editor.graph.getHeight() !== editorSize.height + ) { + editor.graph.changeSize(editorSize.width, editorSize.height); } if (editor.selectedId) { diff --git a/src/components/inspector.tsx b/src/components/inspector.tsx index dc954f8..57e5925 100644 --- a/src/components/inspector.tsx +++ b/src/components/inspector.tsx @@ -355,8 +355,13 @@ const TreeInspector: FC = () => {

{t("tree.group")}

- - + +