keep index when toggle case

This commit is contained in:
codetypes committed 2024-04-28 22:29:54 +08:00
1 parent 098894b63f
commit 7b1d14c3b2
1 file changed
+4 -3
+4 -3
View File
@@ -151,11 +151,11 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
filterNodes(option, findDataById("1")); filterNodes(option, findDataById("1"));
setFilterOption({ setFilterOption({
...option, ...option,
index: 0,
}); });
if (option.results.length > 0) { if (option.results.length > 0) {
editor.graph.focusItem(option.results[0]); const idx = option.index < option.results.length ? option.index : 0;
selectNode(option.results[0]); editor.graph.focusItem(option.results[idx]);
selectNode(option.results[idx]);
} else { } else {
selectNode(null); selectNode(null);
} }
@@ -1105,6 +1105,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
onSearchChange({ onSearchChange({
...filterOption, ...filterOption,
filterStr: e.currentTarget.value, filterStr: e.currentTarget.value,
index: 0,
}) })
} }
onKeyDown={(e) => e.code === Hotkey.Enter && nextResult()} onKeyDown={(e) => e.code === Hotkey.Enter && nextResult()}