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

add disabled prop to EuiComboBoxOption #650

Merged
merged 3 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `0.0.40`.
- add disabled prop to `EuiComboBoxOption` ([#650](https://github.com/elastic/eui/pull/650))

# [`0.0.40`](https://github.com/elastic/eui/tree/v0.0.40)

Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/views/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class extends Component {
label: 'Titan',
'data-test-subj': 'titanOption',
}, {
label: 'Enceladus',
label: 'Enceladus is disabled',
disabled: true,
}, {
label: 'Mimas',
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
color: $euiColorPrimary;
background-color: $euiFocusBackgroundColor;
}
&:disabled {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a rule to override the hover state:

  &:disabled {
    color: $euiColorMediumShade;
    cursor: not-allowed;
    &:hover {
      text-decoration: none;
    }
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

Been dealing with these kinds of conflicts a lot lately. Another way to deal with this kind of stuff is to only apply hover states when &:enabled:hover. Cuts out the need for extra specificity overwrites.

No need to do that here, just was a fun realization I had last week and wanted to share. I didn't even know enabled was a thing.

color: $euiColorMediumShade;
cursor: not-allowed;
&:hover {
text-decoration: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class EuiComboBoxOption extends Component {
optionRef: PropTypes.func,
onClick: PropTypes.func.isRequired,
onEnterKey: PropTypes.func.isRequired,
disabled: PropTypes.bool,
}

onClick = () => {
Expand All @@ -38,6 +39,7 @@ export class EuiComboBoxOption extends Component {
option, // eslint-disable-line no-unused-vars
onClick, // eslint-disable-line no-unused-vars
onEnterKey, // eslint-disable-line no-unused-vars
disabled,
...rest
} = this.props;

Expand All @@ -54,6 +56,7 @@ export class EuiComboBoxOption extends Component {
onKeyDown={this.onKeyDown}
ref={optionRef}
tabIndex="-1"
disabled={disabled}
{...rest}
>
{children}
Expand Down