EuiSuperSelect - check for empty string before setting defaultValue#1319
Merged
nreese merged 4 commits intoelastic:masterfrom Nov 20, 2018
Merged
EuiSuperSelect - check for empty string before setting defaultValue#1319nreese merged 4 commits intoelastic:masterfrom
nreese merged 4 commits intoelastic:masterfrom
Conversation
cchaos
approved these changes
Nov 19, 2018
|
|
||
| this.state = { | ||
| value: this.options[1].value, | ||
| value: '', |
Contributor
There was a problem hiding this comment.
Probably didn't mean to commit changes to the example?
Contributor
Author
There was a problem hiding this comment.
I figured having an example with an empty initial selection would not hurt but I can revert the change if you would like
Contributor
There was a problem hiding this comment.
Understandable, though I'd almost rather have an example specifically for empty initials instead of applying to a current example.
CHANGELOG.md
Outdated
|
|
||
| - `EuiBasicTable` now converts the `EuiTableRowCell` `header` into `undefined` if it's been provided as a non-string node, hiding the header and preventing the node from being rendered as `[object Object]` on narrow screens ([#1312](https://github.com/elastic/eui/pull/1312)) | ||
| - Fixed `fullWidth` size of `EuiComboBox`, a regression introduced in `4.7.0` ([#1314](https://github.com/elastic/eui/pull/1314)) | ||
| - `EuiSuperSelect`, do not set value and defaultValue on input when EuiSuperSelect is passed empty string for `valueOfSelected` prop ([#1319](https://github.com/elastic/eui/pull/1319)) |
Contributor
There was a problem hiding this comment.
Suggested change
| - `EuiSuperSelect`, do not set value and defaultValue on input when EuiSuperSelect is passed empty string for `valueOfSelected` prop ([#1319](https://github.com/elastic/eui/pull/1319)) | |
| - Fixed error when passing empty string as `value` prop for `EuiSuperSelect` ([#1319](https://github.com/elastic/eui/pull/1319)) |
chandlerprall
suggested changes
Nov 19, 2018
| // https://reactjs.org/docs/uncontrolled-components.html#default-values | ||
| let selectDefaultValue; | ||
| if (!value) { | ||
| if (!value && value !== '') { |
Contributor
There was a problem hiding this comment.
Instead, let's change that original !value to value == null to avoid JavaScript's truthiness weirdness. This solves this '' use case but also any other, as value can be any type of React node like false or 0
Suggested change
| if (!value && value !== '') { | |
| if (value == null) { |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If you provide
EuiSuperSelectwith an empty value'', then a react warning is displayedThis PR verifies that value is not
''before setting the defaultValue