I have a dropdown in React Select, i am facing an issue with the focus. The first item in the option list is getting focused whenever we open the dropdown. There are couple of props that gets passed, but none of them is used to disable this feature. I saw issues related to autofocus mentioned in their github. But the prop is still not added in their package.
I tried with focus props, but i am not getting the desired result.
Here is my code for the Select Dropdown.
<Select
className="profile-module-select-container"
classNamePrefix="profile-module-select"
defaultValue={{value: 0, label: 0}}
options={options}
openMenuOnFocus={false}
autoFocus={options.isFocused}
styles={styles}
onChange={selected => {
this.setState({
optionSelect: selected.value
}, () => {onChange(this.state.optionSelect, formKey)});
}}
onMenuOpen={(e, i, o) => {
this.setState({
selectMenuOpen: true
});
}}
onMenuClose={() => {
this.setState({
selectMenuOpen: false
});
}}
components={
{
IndicatorSeparator:() => null,
DropdownIndicator: DropdownCaret,
Placeholder: CustomPlaceholder,
Option: CustomOptionComponent
}
}
placeholder={placeholder}
isSearchable={false}
isClearable={false}
name={name}
value={options.filter(option => {return option.value === value})}
/>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…