From 7b1d14c3b2e674d111283f4b398c8da638f2ac7d Mon Sep 17 00:00:00 2001 From: codetypes Date: Sun, 28 Apr 2024 22:29:54 +0800 Subject: [PATCH] keep index when toggle case --- src/components/editor.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/editor.tsx b/src/components/editor.tsx index 7b1e84f..709f35f 100644 --- a/src/components/editor.tsx +++ b/src/components/editor.tsx @@ -151,11 +151,11 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . filterNodes(option, findDataById("1")); setFilterOption({ ...option, - index: 0, }); if (option.results.length > 0) { - editor.graph.focusItem(option.results[0]); - selectNode(option.results[0]); + const idx = option.index < option.results.length ? option.index : 0; + editor.graph.focusItem(option.results[idx]); + selectNode(option.results[idx]); } else { selectNode(null); } @@ -1105,6 +1105,7 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . onSearchChange({ ...filterOption, filterStr: e.currentTarget.value, + index: 0, }) } onKeyDown={(e) => e.code === Hotkey.Enter && nextResult()}