diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/AsyncSelectList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/AsyncSelectList.tsx index c10ba590800..9a1db2f210a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/AsyncSelectList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/AsyncSelectList.tsx @@ -286,6 +286,13 @@ const AsyncSelectList: FC = ({ onChange?.(selectedValues); }; + const handleDropdownChange = (open: boolean) => { + if (!open) { + // Close the form when the dropdown closes + onCancel && onCancel(); + } + }; + useEffect(() => { loadOptions(''); }, []); @@ -314,6 +321,7 @@ const AsyncSelectList: FC = ({ style={{ width: '100%' }} tagRender={customTagRender} onChange={handleChange} + onDropdownVisibleChange={handleDropdownChange} onInputKeyDown={(event) => { if (event.key === 'Backspace') { return event.stopPropagation(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx index 31f8e2ebfe0..9ed6a8e2f82 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/AsyncSelectList/TreeAsyncSelectList.tsx @@ -267,6 +267,13 @@ const TreeAsyncSelectList: FC> = ({ } }, 300); + const handleDropdownChange = (open: boolean) => { + if (!open) { + // Close the form when the dropdown closes + onCancel && onCancel(); + } + }; + useEffect(() => { if (glossaries.length) { expandableKeys.current = glossaries.map((glossary) => glossary.id); @@ -327,6 +334,7 @@ const TreeAsyncSelectList: FC> = ({ treeData={treeData} treeExpandedKeys={isEmpty(searchOptions) ? undefined : expandedRowKeys} onChange={handleChange} + onDropdownVisibleChange={handleDropdownChange} onSearch={onSearch} onTreeExpand={setExpandedRowKeys} {...props}