solve the problem of no search without collapsed

This commit is contained in:
George Shi committed 2024-05-09 11:29:19 +08:00
1 parent cde6608313
commit 0d50a4590a
1 file changed
+17
+17
View File
@@ -161,6 +161,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
});
if (option.results.length > 0) {
const idx = option.index < option.results.length ? option.index : 0;
recursiveOpenCollapsed(option.results[idx]);
editor.graph.focusItem(option.results[idx]);
selectNode(option.results[idx]);
} else {
@@ -1079,6 +1080,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
const { results, index } = filterOption;
if (results.length > 0) {
const idx = (index + 1) % results.length;
recursiveOpenCollapsed(results[idx]);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
setFilterOption({ ...filterOption, index: idx });
@@ -1089,6 +1091,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
const { results, index } = filterOption;
if (results.length > 0) {
const idx = (index + results.length - 1) % results.length;
recursiveOpenCollapsed(results[idx]);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
setFilterOption({ ...filterOption, index: idx });
@@ -1133,6 +1136,20 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
}
};
const recursiveOpenCollapsed = (id: string) => {
const recursiveFun = (searchId: string) => {
const data = findDataById(searchId);
if (searchId !== id && data.collapsed) {
data.collapsed = undefined;
}
if (data.parent) {
recursiveFun(data.parent);
}
}
recursiveFun(id);
updateGrahp();
}
return (
<div
{...props}