Skip to content

Commit

Permalink
fix(react): fix dropdown disabled state not closing upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Sep 29, 2022
1 parent 26c7743 commit 2b18843
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/react/lib/Dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ const Dropdown = forwardRef(({
});
const { x, y, reference, floating, strategy, context } = useFloating({
open: state.opened,
onOpenChange: o => {
dispatch({ opened: o });
onToggle?.({ opened: o });
},
onOpenChange: (...args) => onOpenChange(...args),
placement,
strategy: 'fixed',
whileElementsMounted: autoUpdate,
Expand Down Expand Up @@ -88,6 +85,15 @@ const Dropdown = forwardRef(({
innerRef,
}));

const onOpenChange = o => {
if (disabled && o) {
return;
}

dispatch({ opened: o });
onToggle?.({ opened: o });
};

const toggle = () => {
if (disabled) {
return;
Expand Down

0 comments on commit 2b18843

Please sign in to comment.