Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#348] [Select] Rm Unused menuControls Prop #369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function Select({
forceTheme,
ghostColor,
maxHeight,
menuControls,
placeholder,
size = Size.LARGE,
value,
Expand All @@ -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;
Expand All @@ -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 = () => (
Expand Down Expand Up @@ -105,26 +102,22 @@ export default function Select({
});
});

const renderOptionMenu = () => (
<Dropdown
portal
buttonRef={selectTriggerRef}
setShowDropdown={() => toggleOpen()}
showDropdown={isOpen}
fullWidth={fullWidth}
maxHeight={maxHeight}
zIndex={zIndex}
>
{renderSelectItems()}
</Dropdown>
);

return (
<SelectContainer $width={width}>
{/* Field */}
{disabled ? renderDisabledField() : renderEnabledField()}
{/* Option menu */}
{renderOptionMenu()}
<Dropdown
portal
buttonRef={selectTriggerRef}
setShowDropdown={() => toggleOpen()}
showDropdown={menuOpen}
fullWidth={fullWidth}
maxHeight={maxHeight}
zIndex={zIndex}
>
{renderSelectItems()}
</Dropdown>
</SelectContainer>
);
}
5 changes: 0 additions & 5 deletions src/components/Select/Select.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down