From f1f513897d0816c8c9dc005efe83db118bf1084e Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Tue, 14 Nov 2023 17:04:09 -0800 Subject: [PATCH] :beetle: Fix opening overlapping dropdown body without this fix, a dropdown with a dropdown body that overlaps the trigger will close immediately onMouseUp --- packages/dropdown/src/Dropdown.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/dropdown/src/Dropdown.tsx b/packages/dropdown/src/Dropdown.tsx index 7cef0c5f..8d6fb44b 100644 --- a/packages/dropdown/src/Dropdown.tsx +++ b/packages/dropdown/src/Dropdown.tsx @@ -348,7 +348,13 @@ export default function Dropdown({ // If dropdown has no items and click was within dropdown body, do nothing if (!hasItemsRef.current) return; - handleSubmitItem(event); + // If still isOpening, only trigger submit with an active element + if ( + !isOpeningRef.current || + getActiveItemElement(dropdownElementRef.current) + ) { + handleSubmitItem(event); + } }, [closeDropdown, handleSubmitItem, onMouseUp], );