JedWatson / JedWatson/react-select
react-select: 5.8.0 - Selected option only appears in input after focus is lost
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
I am currently developing a react (18) NextJS (14.2.5) application using Google Maps AutocompleteService. What I am experiencing is the selected value is not populating the input value unless the focus is lost on the element. I have verified that state is being updated.
const customStyles = {
dropdownIndicator: (provided) => ({
...provided,
display: 'none',
}),
indicatorSeparator: (provided) => ({
...provided,
display: 'none',
}),
container: (provided) => ({
...provided,
width: '100%',
maxWidth: '600px',
margin: '0 auto',
}),
input: (provided) => ({
...provided,
width: '100%',
}),
singleValue: (provided) => ({
...provided,
color: 'black', // Set the text color for selected value
}),
option: (provided) => ({
...provided,
color: 'black', // Set the text color for options
}),
menu: (provided) => ({
...provided,
width: '100%', // Ensure the menu width is responsive
}),
control: (provided, state) => ({
...provided,
borderColor: state.isFocused ? 'blue' : 'gray', // Change border color on focus
boxShadow: state.isFocused ? '0 0 0 1px blue' : 'none', // Add shadow on focus
}),
};
<Select
inputValue={query}
onInputChange={(newValue) => setQuery(newValue)}
onChange={(selected) => {
setQuery(selected ? selected.label : '');
setSelectedOption(selected);
}}
options={options}
placeholder="Search places..."
className=""
classNamePrefix="select"
styles={customStyles}
value={selectedOption}
isClearable
/>
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
No repository file or test is identified in the report. Start by reproducing the controlled Select example with React 18 and NextJS 14.2.5, focusing on the interaction between inputValue, onInputChange, onChange, and value. Done means the selected option's label appears in the input immediately after selection without requiring focus to be lost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100