AsyncCreatable LOSES FOCUS WHEN OPTIONS ARRIVES FROM API
See original GitHub issueI am using the async-Creatable field which looks like the below. When options arrive from the API call, Select Field losses focus from the text-area and if I click the text area again it will clear text-field. I saw this suggestion
You can fix this by either moving the Input definition outside render(), or commenting out the inputValue/onInputChange props.
But it’s not working for me.
<AsyncCreatable
components={selectComponents}
name={name}
styles={{ menuPortal: base => ({ ...base, zIndex: 9999 }) }}
menuPortalTarget={shouldPortal ? document.body : null}
onChange={onChange}
onCreateOption={handleCreate}
closeMenuOnScroll
value={value}
formatCreateLabel={inputVal => `${createLabel || 'create'} "${inputVal}"`}
isValidNewOption={isValidNewOption}
loadOptions={promiseOptions}
{...selectProps}
{...restInput}
/>
const selectComponents = ({
Control: props => <ControlComponent controlProps={props} label={label} required={required} value={value} name={name} />,
ValueContainer,
Menu,
Option: props => <Option optionProps={props} rest={rest} />
});
Please let me know how can I fix this problem .
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
React-Select Custom Input Losing Focus - Stack Overflow
I've built my input in such a way that when the select is typed into, a debounced network request fires and then the...
Read more >API - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect, autocomplete and ajax support.
Read more >API - React Select
Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array. function (....
Read more >react-select losing focus for custom component "valuecontainer"
I am using the async-Creatable field which looks like the below. When options arrive from the API call, Select Field losses focus from...
Read more >react-select-legacy - npm
Options should be provided as an Array of Object s, each with a value and ... props can be a mix of Async,...
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
@somilkhandelwal Try moving your
selectComponents
variable outside of yourrender
function, preferably outside of your component.Working fine now. This solves my problem. https://github.com/JedWatson/react-select/issues/2810#issuecomment-569117980