Dropdown does not appear on clicking inside value but appears on click of down arrow icon in React Select
See original GitHub issueI am using Multi Select and want to render just 1 item and then show additional selected item as +(this) more inside the selected area, it works fine when there is no value selected, but when the select component is populated from api response i.e when it already has value inside it the dropdown doesn’t appear on clicking of the area where selected value are shown but it opens when I click on down arrow icon. I am using styled component for styling. I asked in StackOverflow but didn’t got any answer, so posting here hope I get some solution. `
const ValueContainer = ({ children, getValue, hasValue, ...props }) => {
let maxToShow = 1;
let length = getValue().length;
let displayChips = React.Children.toArray(children).slice(0, maxToShow);
let shouldBadgeShow = length > maxToShow;
let displayLength = length - maxToShow;
if (!hasValue) {
return (
<components.ValueContainer {...props}>
{children}
</components.ValueContainer>
);
}
return (
<components.ValueContainer {...props}>
{!props.selectProps.inputValue && displayChips}
<Div
fontSize={0}
fontWeight={5}
color="#4380FF"
ml="auto"
pl="3px"
minWidth="56px">
{shouldBadgeShow && `+ ${displayLength} more`}
</Div>
</components.ValueContainer>
);
};
const Option = props => {
return (
<Div>
<components.Option {...props}>
<Flex alignItems="center">
<CheckBox
checked={props.isSelected}
width="20px"
height="20px"
mr="10px"
/>
<Div width={0.85}>{props.label} </Div>
</Flex>
</components.Option>
</Div>
);
};
<Select
classNamePrefix="faq__dropdown"
className={
'faq__dropdown--empty'
}
isClearable={false}
isSearchable={false}
isMulti
hideSelectedOptions={false}
closeMenuOnSelect={false}
components={{ Option, MultiValue }}
options={attributeMsgs}
value={selectedAttributeMsgs}
onChange={e => handleAttributeMsg(e)}
/>
`
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
react-select, down arrow is not opening the dropdown
1", down arrow won't open the menu. I see this work in demo examples and I am using the same code. <Select id="state-select"...
Read more >react-select dropdown doesn't show dropdown menu ... - Reddit
However, when adding it to the page I want to display it on, while the bar itself shows, clicking it does nothing but...
Read more >Dropdown - Multiselect - Carbon Design System
Dropdowns present a list of options from which a user can select one option, or several. ... dropdown, click the “x” icon next...
Read more >Dropdown - Ant Design
When there are more than a few options to choose from, you can wrap them in a Dropdown . By hovering or clicking...
Read more >Dropdown | Webflow University
The Menu is set to Show in the Dropdown settings of the Settings panel. By default, the dropdown list appears when a user...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ebonow I was able to solve the issue, Thanks for the help.
@Shivraj97 the solution you are referring to filters out all children elements of the ValueContainer including the Placeholder. You would need to make sure you specify it as a filtered item. If you wanted to achieve it with the solution that was recommended then it would look similar to this:
It’s also worth noting that there is a prop called
controlShouldRenderValue
which will filter out the value component for you so it could be better simplified by removing all of the filtering and just passing in that prop as true with the extra JSX you want to put in the ValueContainer.