From 37f8577e59885f641db65db85811a1779bdbc375 Mon Sep 17 00:00:00 2001 From: George Shi Date: Tue, 19 Nov 2024 16:49:57 +0800 Subject: [PATCH] fix keyboardEvent enter will add new nodes when search next node --- src/components/editor.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/editor.tsx b/src/components/editor.tsx index 111e896..e4d065d 100644 --- a/src/components/editor.tsx +++ b/src/components/editor.tsx @@ -42,6 +42,7 @@ interface FilterOption { filterFocus: boolean; filterType: "content" | "id"; placeholder: string; + isFocused: boolean; } const createMenu = () => { @@ -151,6 +152,7 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . filterFocus: true, filterType: "content", placeholder: "", + isFocused: false }); const onSearchChange = (option: FilterOption) => { @@ -516,6 +518,10 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . }; const createNode = () => { + if (filterOption.isFocused) { + return; + } + if (!editor.selectedId) { message.warning(t("node.noNodeSelected")); return; @@ -1188,6 +1194,8 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . index: 0, }) } + onFocus={() => setFilterOption({ ...filterOption, isFocused: true })} + onBlur={() => setFilterOption({ ...filterOption, isFocused: false })} onKeyDown={handleKeyDown} suffix={ @@ -1266,6 +1274,7 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . filterStr: "", filterType: "content", placeholder: "", + isFocused: false }); keysRef.current?.focus(); }}