Add autoFocusOption prop to disable focusing an option until the user provides input#6067
Add autoFocusOption prop to disable focusing an option until the user provides input#60676uzm4n wants to merge 2 commits intoJedWatson:masterfrom
Conversation
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
@Methuselah96 this is a highly requested feature that would be nice to have for a lot of people 🙏🏻 |
This PR builds on #4080 and #3705, updating it to support the most recent version of React Select.
The
autoFocusOptionprop 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:isMultiselect withcloseMenuOnSelectset 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:
tabSelectsValuewhile 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.