diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx index 8c3dda6..b4fb2a0 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx @@ -69,14 +69,18 @@ export const Dropdown: React.FC & { }, }) + const handleToggle = (open: boolean) => { + if (isControlled) { + onToggle && onToggle(open) + } else { + setOpenState(open) + } + } + const onTrigger = () => { if (disabled) return - if (isControlled) { - onToggle && onToggle(!open) - } else { - setOpenState(!open) - } + handleToggle(!open) } useEffect(() => { @@ -161,13 +165,7 @@ export const Dropdown: React.FC & { { - if (isControlled) { - onToggle && onToggle(false) - } else { - setOpenState(false) - } - }} + onClose={() => handleToggle(false)} size={size} genericFontFamily={props.genericFontFamily} >