From 5c9c23fd30aa0e3e869b6c5ecea61cc2e5dd9c12 Mon Sep 17 00:00:00 2001 From: jongomez Date: Fri, 29 Sep 2023 13:08:47 +0100 Subject: [PATCH] fix: removed the incorrect useEffect and updated deps array --- packages/lsd-react/src/components/Dropdown/Dropdown.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx index dd5a29a..91e0a78 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx @@ -83,10 +83,9 @@ export const Dropdown: React.FC & { handleToggle(!openState) } - // Handle the controlled version of the component: useEffect(() => { - typeof isOpen !== 'undefined' && setOpenState(isOpen) - }, [isOpen]) + if (disabled && openState && !isControlled) setOpenState(false) + }, [openState, disabled, isControlled]) const buttonId = props?.id ?? (props.id || 'dropdown') + '-input'