From ce5a4ff786177d7d6470edcd21f24130a0092945 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 25 Mar 2025 15:21:03 -0300 Subject: [PATCH] fix: Improve tool metadata and dropdown state management (#7257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 (component.py): Fix issue where tags attribute may not exist on tool object 🐛 (index.tsx): Fix bug where value may not be included in options before setting it * 🐛 (component.py): fix issue where tags list is empty if tool.tags is not defined, now default to [tool.name] to ensure at least one tag is present --------- Co-authored-by: Edwin Jose --- .../base/langflow/custom/custom_component/component.py | 2 +- .../src/components/core/dropdownComponent/index.tsx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/custom/custom_component/component.py b/src/backend/base/langflow/custom/custom_component/component.py index c780a8931..13b9623b5 100644 --- a/src/backend/base/langflow/custom/custom_component/component.py +++ b/src/backend/base/langflow/custom/custom_component/component.py @@ -1166,7 +1166,7 @@ class Component(CustomComponent): { "name": tool.name, "description": tool.description, - "tags": tool.tags, + "tags": tool.tags if hasattr(tool, "tags") and tool.tags else [tool.name], "status": True, # Initialize all tools with status True } for tool in tools diff --git a/src/frontend/src/components/core/dropdownComponent/index.tsx b/src/frontend/src/components/core/dropdownComponent/index.tsx index eed5ba29a..d0c4550f5 100644 --- a/src/frontend/src/components/core/dropdownComponent/index.tsx +++ b/src/frontend/src/components/core/dropdownComponent/index.tsx @@ -62,6 +62,12 @@ export default function Dropdown({ const [refreshOptions, setRefreshOptions] = useState(false); const refButton = useRef(null); + value = useMemo(() => { + if (!options.includes(value)) { + return null; + } + return value; + }, [value, options]); // Initialize utilities and constants const placeholderName = name ? formatPlaceholderName(name)