Skip to content

Commit

Permalink
🪲 Fix opening overlapping dropdown body
Browse files Browse the repository at this point in the history
without this fix, a dropdown with a dropdown body that overlaps the trigger will close immediately onMouseUp
  • Loading branch information
acusti committed Nov 15, 2023
1 parent e809e78 commit f1f5138
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/dropdown/src/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
);
Expand Down

0 comments on commit f1f5138

Please sign in to comment.