Merge pull request #29 from GeorgeShiZZZ/dev

fix keyboardEvent enter will add new nodes when search next node
This commit is contained in:
codetypes authored and GitHub committed 2024-11-20 14:55:50 +08:00
commit a30f5d1c26
1 file changed
+9
+9
View File
@@ -42,6 +42,7 @@ interface FilterOption {
filterFocus: boolean; filterFocus: boolean;
filterType: "content" | "id"; filterType: "content" | "id";
placeholder: string; placeholder: string;
isFocused: boolean;
} }
const createMenu = () => { const createMenu = () => {
@@ -151,6 +152,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
filterFocus: true, filterFocus: true,
filterType: "content", filterType: "content",
placeholder: "", placeholder: "",
isFocused: false
}); });
const onSearchChange = (option: FilterOption) => { const onSearchChange = (option: FilterOption) => {
@@ -516,6 +518,10 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
}; };
const createNode = () => { const createNode = () => {
if (filterOption.isFocused) {
return;
}
if (!editor.selectedId) { if (!editor.selectedId) {
message.warning(t("node.noNodeSelected")); message.warning(t("node.noNodeSelected"));
return; return;
@@ -1188,6 +1194,8 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
index: 0, index: 0,
}) })
} }
onFocus={() => setFilterOption({ ...filterOption, isFocused: true })}
onBlur={() => setFilterOption({ ...filterOption, isFocused: false })}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
suffix={ suffix={
<Flex gap="2px" style={{ alignItems: "center" }}> <Flex gap="2px" style={{ alignItems: "center" }}>
@@ -1266,6 +1274,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
filterStr: "", filterStr: "",
filterType: "content", filterType: "content",
placeholder: "", placeholder: "",
isFocused: false
}); });
keysRef.current?.focus(); keysRef.current?.focus();
}} }}