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 an invalid state to EuiSuperSelect #1804

Merged
merged 7 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Converted `EuiTableHeaderMobile` to TS ([#1786](https://github.com/elastic/eui/pull/1786))
- Added `menuLeft` and `menuRight` icons ([#1797](https://github.com/elastic/eui/pull/1797))
- Updated EuiNavDrawer’s collapse/expand button to use `menuLeft` and `menuRight` icons ([#1797](https://github.com/elastic/eui/pull/1797))
- Added `isInvalid` prop to `EuiSuperSelect` ([#1804](https://github.com/elastic/eui/pull/1804))

## [`9.8.0`](https://github.com/elastic/eui/tree/v9.8.0)

Expand Down
9 changes: 9 additions & 0 deletions src-docs/src/views/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ export default class extends Component {

<EuiSpacer size="m" />

<EuiSuperSelect
options={this.options}
valueOfSelected={this.state.value}
onChange={this.onChange}
isInvalid
/>

<EuiSpacer size="m" />

<EuiSuperSelect
options={this.options}
valueOfSelected={this.state.value}
Expand Down
4 changes: 4 additions & 0 deletions src/components/form/super_select/_super_select_control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
text-overflow: ellipsis;
white-space: nowrap;

&--isInvalid {
@include euiFormControlInvalidStyle;
}

&--compressed {
line-height: $euiFormControlCompressedHeight; /* 2 */
padding-top: 0; /* 2 */
Expand Down
6 changes: 6 additions & 0 deletions src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export class EuiSuperSelect extends Component {
valueOfSelected,
onChange,
isOpen,
isInvalid,
hasDividers,
itemClassName,
itemLayoutAlign,
Expand Down Expand Up @@ -199,6 +200,7 @@ export class EuiSuperSelect extends Component {
onKeyDown={this.onSelectKeyDown}
className={buttonClasses}
fullWidth={fullWidth}
isInvalid={isInvalid}
{...rest}
/>
);
Expand Down Expand Up @@ -302,6 +304,10 @@ EuiSuperSelect.propTypes = {
* Make it wide
*/
fullWidth: PropTypes.bool,
/**
* Provides invalid styling
*/
isInvalid: PropTypes.bool,
/**
* Make it short
*/
Expand Down
2 changes: 2 additions & 0 deletions src/components/form/super_select/super_select_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const EuiSuperSelectControl = ({
name,
fullWidth,
isLoading,
isInvalid,
defaultValue,
compressed,
value,
Expand All @@ -27,6 +28,7 @@ export const EuiSuperSelectControl = ({
'euiSuperSelectControl--fullWidth': fullWidth,
'euiSuperSelectControl--compressed': compressed,
'euiSuperSelectControl-isLoading': isLoading,
'euiSuperSelectControl--isInvalid': isInvalid,
snide marked this conversation as resolved.
Show resolved Hide resolved
},
className
);
Expand Down