Skip to content

Commit

Permalink
refactor(dropdown.tsx): added search input and container props moved …
Browse files Browse the repository at this point in the history
…input out of valueitem

Headstorm#440
  • Loading branch information
j-leidy committed Jul 11, 2023
1 parent 9e47052 commit f1d3d15
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ const ValueItemTagContainer = styled(Tag.Container)`
`}
`;

const StyledSearchContainer = styled(StyledBaseDiv)``;
const SearchContainer = styled(StyledBaseDiv)`
`;

const StyledSearchInput = styled(StyledBaseInput)`
const SearchInput = styled(StyledBaseInput)`
all: inherit;
text-align: left;
`;

export interface DropdownProps {
Expand All @@ -242,6 +245,8 @@ export interface DropdownProps {
StyledPlaceholder?: StyledSubcomponentType;
StyledCloseIconContainer?: StyledSubcomponentType;
StyledArrowIconContainer?: StyledSubcomponentType;
StyledSearchInput?: StyledSubcomponentType;
StyledSearchContainer?: StyledSubcomponentType;

containerProps?: SubcomponentPropsType;
valueContainerProps?: SubcomponentPropsType;
Expand All @@ -253,6 +258,7 @@ export interface DropdownProps {
placeholderProps?: SubcomponentPropsType;
closeIconProps?: SubcomponentPropsType;
arrowIconProps?: SubcomponentPropsType;
inputProps?: SubcomponentPropsType;

containerRef?: React.RefObject<HTMLElement>;
optionsContainerRef?: React.RefObject<HTMLElement>;
Expand All @@ -265,6 +271,8 @@ export interface DropdownProps {
placeholderRef?: React.RefObject<HTMLElement>;
closeIconRef?: React.RefObject<HTMLElement>;
arrowIconRef?: React.RefObject<HTMLElement>;
inputContainerRef?: React.RefObject<HTMLElement>;
inputRef?: React.RefObject<HTMLElement>;

color?: string;
elevation?: number;
Expand Down Expand Up @@ -314,6 +322,8 @@ const Dropdown = ({
StyledPlaceholder = PlaceholderContainer,
StyledCloseIconContainer = CloseIconContainer,
StyledArrowIconContainer = ArrowIconContainer,
StyledSearchContainer = SearchContainer,
StyledSearchInput = SearchInput,

containerProps,
valueContainerProps,
Expand Down Expand Up @@ -883,7 +893,7 @@ const Dropdown = ({
...(valueContainerProps ? valueContainerProps.containerProps : {}),
}}
>
{searchCharacterCount === 0 && (!values || !values.length) && (
{(searchCharacterCount === 0 && (!values || !values.length) && !focusWithin )&& (
<StyledPlaceholder
ref={placeholderRef}
id={`${name}-placeholder`}
Expand Down Expand Up @@ -916,7 +926,8 @@ const Dropdown = ({
</Tag>
) : undefined,
)}
{searchable && (
</StyledValueItem>
{searchable && focusWithin && (
<TextInput
id={`${name}-search-input`}
aria-label={`${name}-search-input`}
Expand All @@ -928,7 +939,6 @@ const Dropdown = ({
inputRef={searchInputRef}
/>
)}
</StyledValueItem>
{closeIcons}
</Button>
{isOpen && (
Expand Down

0 comments on commit f1d3d15

Please sign in to comment.