From 466864afe362d784983174bbc10c89cbdbefee91 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Wed, 15 Apr 2026 16:46:47 +0800 Subject: [PATCH] fix(web): Cancel variable snapshot --- .../components/Properties/VariableSelect.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/web/src/views/Workflow/components/Properties/VariableSelect.tsx b/web/src/views/Workflow/components/Properties/VariableSelect.tsx index 5523c06e..203dd850 100644 --- a/web/src/views/Workflow/components/Properties/VariableSelect.tsx +++ b/web/src/views/Workflow/components/Properties/VariableSelect.tsx @@ -40,7 +40,7 @@ const VariableSelect: FC = ({ const { t } = useTranslation(); const [open, setOpen] = useState(false); const [search, setSearch] = useState(''); - const [expandedParent, setExpandedParent] = useState(null); + const [expandedParentKey, setExpandedParentKey] = useState(null); const [dropdownPos, setDropdownPos] = useState({ top: 0, left: 0, width: 0 }); const [childPanelPos, setChildPanelPos] = useState({ top: 0, right: 0 }); const containerRef = useRef(null); @@ -84,6 +84,10 @@ const VariableSelect: FC = ({ ? filteredOptions.find(o => o.children?.some(c => `{{${c.value}}}` === value)) : undefined; + const expandedParent = expandedParentKey + ? filteredOptions.find(o => o.key === expandedParentKey) ?? null + : null; + const groupedSuggestions = filteredOptions.reduce((groups: Record, s) => { const nodeId = s.nodeData.id as string; if (!groups[nodeId]) groups[nodeId] = []; @@ -139,7 +143,7 @@ const VariableSelect: FC = ({ ) { setOpen(false); setSearch(''); - setExpandedParent(null); + setExpandedParentKey(null); setChildPanelPos({ top: 0, right: 0 }); } }; @@ -159,7 +163,7 @@ const VariableSelect: FC = ({ onChange?.(`{{${suggestion.value}}}`, suggestion); setOpen(false); setSearch(''); - setExpandedParent(null); + setExpandedParentKey(null); } }; @@ -312,16 +316,16 @@ const VariableSelect: FC = ({ if (s.disabled) return; if (hasChildren) { updateChildPos(s.key); - setExpandedParent(prev => prev?.key === s.key ? null : s); + setExpandedParentKey(prev => prev === s.key ? null : s.key); } handleSelect(s); }} onMouseEnter={() => { if (hasChildren) { updateChildPos(s.key); - setExpandedParent(s); + setExpandedParentKey(s.key); } else { - setExpandedParent(null); + setExpandedParentKey(null); } }} > @@ -358,7 +362,7 @@ const VariableSelect: FC = ({ id="variable-select-child-panel" className="rb:min-w-70 rb:max-h-57.5 rb:overflow-y-auto rb:text-[12px] rb:fixed rb:z-1000 rb:bg-white rb:rounded-lg rb:border-[0.5px] rb:border-[#EBEBEB] rb:shadow-[0px_2px_6px_0px_rgba(0,0,0,0.1)] rb:py-3 rb:px-2" style={{ top: childPanelPos.top, right: childPanelPos.right }} - onMouseEnter={() => setExpandedParent(expandedParent)} + onMouseEnter={() => setExpandedParentKey(expandedParentKey)} >