Reputation: 3247
I have Select from antd styled with styled components with different icon. Everything works perfectly, except click on new icon inside of select doesn't trigger the dropdown to open or close.
<Styled.SortSelect
size={size ? size : 'large'}
defaultValue={defaultValue}
suffixIcon={<Styled.Icon />}
getPopupContainer={trigger => {
return trigger;
}}
>
{options.map((option: string) => {
return (
<Styled.SortOption className="custom-option" data-testid="sort-option" key={option} value={option}>
{option}
</Styled.SortOption>
);
})}
</Styled.SortSelect>
Simple demo
https://codesandbox.io/s/broken-arrow-click-nfpc7?file=/src/index.tsx
Upvotes: 3
Views: 4314
Reputation: 12774
It seems to be a bug. Switching to an older version of antd e.g. 4.1.3
seems to solve your error
Upvotes: 2
Reputation: 15722
I think it's a bug. But in the meantime a workaround could be to handle whether the select is open yourself via an onClick
on the icon like this:
export const SortSelect = ({ defaultValue, size, options }: Props) => {
const [open, setOpen] = useState(false);
return (
<Styled.SortSelect
size={size ? size : "large"}
defaultValue={defaultValue}
suffixIcon={<Styled.Icon onClick={() => setOpen(!open)} />}
open={open}
getPopupContainer={trigger => {
return trigger;
}}
>
{options.map((option: string) => {
return (
<Styled.SortOption
className="custom-option"
data-testid="sort-option"
key={option}
value={option}
>
{option}
</Styled.SortOption>
);
})}
</Styled.SortSelect>
);
};
Upvotes: 2