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

Remove options defaultProps value from EuiSuperSelect #1975

Merged
merged 4 commits into from
May 29, 2019

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented May 29, 2019

Summary

Fixes #1911, in which the options prop in EuiSuperSelect was not showing as required in the docs Props table. The gist of the problem is that react-docgen resolves all props that have a defaultProps value as not required. Regardless of opinion/correctness there, we should rely on either isRequired or defaultProps in our component definitions.
The fix here is to remove the options defaultProps value.

Checklist

- [ ] This was checked in mobile
- [ ] This was checked in IE11
- [ ] This was checked in dark mode

  • Any props added have proper autodocs

- [ ] Documentation examples were added

  • A changelog entry exists and is marked appropriately
  • This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios

- [ ] This was checked against keyboard-only and screenreader scenarios
- [ ] This required updates to Framer X components

@chandlerprall
Copy link
Contributor

Agreed with your description and removing the default value (why have a select box with no options?)! I think there's a second issue at play here when the provided value is not in the list of options (whether that's the default empty list, or is caused by some other mis-match). The mentioned error occurs when trying to access the inputDisplay of an option that doesn't exist -

if (value) {
const selectedOption = options.find(option => option.value === value);
selectedValue = selectedOption.inputDisplay;
}

  if (value) {
    const selectedOption = options.find(option => option.value === value);
    selectedValue = selectedOption.inputDisplay;
  }

and EuiSuperSelectControl should null-check selectedOption

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM; component no longer breaks locally with bad data

@chandlerprall
Copy link
Contributor

Needs a changelog

@thompsongl thompsongl merged commit 59cb02a into elastic:master May 29, 2019
@thompsongl thompsongl deleted the 1911-euisuperselect-defaultprop branch May 29, 2019 20:40
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.

EuiSuperSelect's options prop isn't marked as required in docs
2 participants