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

Allow disabling of EuiSelect options #324

Merged
merged 5 commits into from
Feb 13, 2018

Conversation

zinckiwi
Copy link
Contributor

@zinckiwi zinckiwi commented Jan 19, 2018

Added a formal property in EuiSelect's options prop of disabled, propagated to the <option> when truthy.

@zinckiwi zinckiwi requested a review from cjcenizal January 19, 2018 15:49
@zinckiwi zinckiwi requested a review from pugnascotia January 19, 2018 16:04
Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Had an idea, what do you think?

if (option.disabled) {
props.disabled = true;
}
return <option {...props}>{option.text}</option>;
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using ...rest to support basic HTML attributes like disabled, value, etc?

{options.map((option, index) => {
  const {
    text,
    ...rest
  } = option;
  return <option {...rest} key={index}>{text}</option>;
})}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I like it

@@ -60,6 +67,7 @@ EuiSelect.propTypes = {
options: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
disabled: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

We can then remove value and disabled from this propType definition since they're just being passed-through.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM!

…ptions-disabled-support

# Conflicts:
#	CHANGELOG.md
@snide snide mentioned this pull request Jan 29, 2018
@snide
Copy link
Contributor

snide commented Feb 6, 2018

@zinckiwi you mind rebasing and merging when you have a moment.

@snide snide merged commit 9898317 into elastic:master Feb 13, 2018
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.

4 participants