JedWatson / JedWatson/react-select
Using custom <components.Input /> component not allowing dropdown to close when clicking outside component
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
react-select version: 5.6.1
I'm trying to overwrite the base <input> element field "auto-complete" to have the value "off" in order to stop the Chrome auto-complete suggestions from appearing. When replacing the <components.Input /> component, the options dropdown does not disappear when clicking outside the component.
I am using a Redux store to persist the state of the <Select /> component.
import Select, {components} from "react-select";
return ["category1", "category2"].map(category => {
const Input = props => (<components.Input {...props} autoComplete="off" />);
return (
<Select
isMulti={true}
options={[{label: "Label 1", value: "1"}, {label: "Label 2", value: "2"}]}
value={reduxStore[attributeCategory.categoryName]}
onChange={selected => {dispatch({type: 'SET_MULTISELECT', payLoad: {category: category, value: selected}})}}
closeMenuOnSelect={false}
components={{Input}}
/>
);
);
When I remove the "components" prop from the <Select /> component, the dropdown works as expected (closes when clicking outside component).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied react-select v5.6.1 reproduction, comparing the default Select behavior with the custom components.Input override and the Redux-controlled value. Investigate the Select and Input entry points to identify why outside clicks do not close the menu; done means autocomplete remains off and the dropdown closes outside the component.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100