Add autoFocusOption prop to disable focusing an option until the user provides input #6067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR builds on #4080 and #3705, updating it to support the most recent version of React Select.
The
autoFocusOption
prop has been tweaked to only disable the default selected option when no user input has been provided, which covers the main two cases where this prop is useful but retains the ability to fill the select using only the keyboard:isMulti
select withcloseMenuOnSelect
set as false, as by default the inputValue is cleared.The latter of the two has been the source of many long-standing issues (#2848, #3324, #3484, #5447), mainly because it made two common patterns difficult at best and impossible at worst:
tabSelectsValue
while having multiple selects withtabIndex
. it was impossible to tab to the next select without selecting an unprompted option.Seeing the proposals of previous issues and PRs I've tried to keep the name of the prop as concise and clear as possible, but if anyone has any better name based on its behavior I'm open to suggestions.
This PR doesn't provide any new example in the docs, as the prop itself is quite simple to understand and I don't think there is any place in the docs where it makes sense to have it. However, if any maintainer thinks that an example would be nice to have, I will be happy to include it.