From d695fce42d37b7ecc376ee303f153656d8b8a6ad Mon Sep 17 00:00:00 2001 From: Khadija Hammoud Date: Tue, 13 Jun 2023 19:55:15 +0300 Subject: [PATCH] Rm Select menuControls --- src/components/Select/Select.tsx | 31 +++++++++++---------------- src/components/Select/Select.types.ts | 5 ----- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/components/Select/Select.tsx b/src/components/Select/Select.tsx index 2d9db6f..771379d 100644 --- a/src/components/Select/Select.tsx +++ b/src/components/Select/Select.tsx @@ -22,7 +22,6 @@ export default function Select({ forceTheme, ghostColor, maxHeight, - menuControls, placeholder, size = Size.LARGE, value, @@ -33,7 +32,6 @@ export default function Select({ }: SelectProps) { // Whether the dropdown is visible or not const [menuOpen, setMenuOpen] = useState(false); - const isOpen = menuControls?.isOpen || menuOpen; const endIcon = menuOpen ? Icon.ChevronUp : Icon.ChevronDown; const typographyWeight = TypographyWeight.REGULAR; @@ -44,8 +42,7 @@ export default function Select({ const toggleOpen = (e?: React.MouseEvent) => { e?.stopPropagation(); - if (!!menuControls) menuControls.setIsOpen(!isOpen); - else setMenuOpen(!isOpen); + setMenuOpen(!menuOpen); }; const renderDisabledField = () => ( @@ -105,26 +102,22 @@ export default function Select({ }); }); - const renderOptionMenu = () => ( - toggleOpen()} - showDropdown={isOpen} - fullWidth={fullWidth} - maxHeight={maxHeight} - zIndex={zIndex} - > - {renderSelectItems()} - - ); - return ( {/* Field */} {disabled ? renderDisabledField() : renderEnabledField()} {/* Option menu */} - {renderOptionMenu()} + toggleOpen()} + showDropdown={menuOpen} + fullWidth={fullWidth} + maxHeight={maxHeight} + zIndex={zIndex} + > + {renderSelectItems()} + ); } diff --git a/src/components/Select/Select.types.ts b/src/components/Select/Select.types.ts index 878d690..b53f503 100644 --- a/src/components/Select/Select.types.ts +++ b/src/components/Select/Select.types.ts @@ -17,11 +17,6 @@ export interface SelectProps { ghostColor?: Color; /** Max dropdown height */ maxHeight?: number | string; - /** For a controlled Select component */ - menuControls?: { - isOpen: boolean; - setIsOpen: (isOpen: boolean) => void; - }; /** Field placeholder text */ placeholder?: string; /** Select size */