Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x Normalise value removal #3416

Merged
merged 2 commits into from
Apr 26, 2019
Merged

3.x Normalise value removal #3416

merged 2 commits into from
Apr 26, 2019

Conversation

gwyneplaine
Copy link
Collaborator

At the moment, if no value is specified by the consumer, it's instantiated as a null value, regardless of whether the select isMulti or not.

When isMulti is false this is fine. On selection of an option, the value becomes an object, and on clearing of said value, it returns to being null. (null --> {} --> null)

However when isMulti is true, this becomes more inconsistent. On selection of options, the value becomes an array of options, removing values extricates them from this array, removing the last selected value results in an empty array, instead of the initial base state of null. (null --> [{}] --> [])

This PR aims to resolve this inconsistency with the view that when isMulti is true, the value should resolve back to a null when no more options are left in the array, especially since the serialized form value is computed from cleanValue(), which converts null values to an empty array anyways.

@JedWatson @jossmac, is there any context behind this decision that I'm not aware of?
As an aside this change will make supporting the isRequired prop substantially less complex.

@gwyneplaine gwyneplaine self-assigned this Feb 8, 2019
@gwyneplaine gwyneplaine changed the title Normalise value removal 3.x Normalise value removal Feb 11, 2019
@gwyneplaine gwyneplaine changed the base branch from master to v3.0.0 April 26, 2019 05:00
@gwyneplaine gwyneplaine merged commit d35afa8 into v3.0.0 Apr 26, 2019
This was referenced May 23, 2019
rodlukas added a commit to rodlukas/UP-admin that referenced this pull request Jun 7, 2019
kvuli updatu react-select@3 se pri smazani vsech clenu uz nenastavi hodnota pole na [], ale null, s cimz kod nepocital (inicializovalo se na []) - viz. JedWatson/react-select#3416
nafg added a commit to nafg/scalajs-facades that referenced this pull request Jun 11, 2020
@dcousens dcousens deleted the normalise-value-removal branch October 19, 2022 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant