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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports[`EuiSuperSelect is rendered 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value=""
/>
Expand Down Expand Up @@ -75,6 +76,7 @@ exports[`EuiSuperSelect props custom display is propagated to dropdown 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value=""
/>
Expand Down Expand Up @@ -231,6 +233,7 @@ exports[`EuiSuperSelect props fullWidth is rendered 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value=""
/>
Expand Down Expand Up @@ -298,6 +301,7 @@ exports[`EuiSuperSelect props more props are propogated to each option 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value="1"
/>
Expand Down Expand Up @@ -462,6 +466,7 @@ exports[`EuiSuperSelect props more props are propogated to each option 2`] = `
data-test-subj="superSelect"
fullWidth={false}
hasDividers={false}
isInvalid={false}
onChange={[Function]}
options={
Array [
Expand All @@ -488,6 +493,7 @@ exports[`EuiSuperSelect props more props are propogated to each option 2`] = `
compressed={false}
data-test-subj="superSelect"
fullWidth={false}
isInvalid={false}
isLoading={false}
onChange={[Function]}
onClick={[Function]}
Expand Down Expand Up @@ -538,6 +544,7 @@ exports[`EuiSuperSelect props more props are propogated to each option 2`] = `
compressed={false}
data-test-subj="superSelect"
fullWidth={false}
isInvalid={false}
isLoading={false}
onChange={[Function]}
onClick={[Function]}
Expand All @@ -559,6 +566,7 @@ exports[`EuiSuperSelect props more props are propogated to each option 2`] = `
value="1"
>
<input
invalid="false"
type="hidden"
value="1"
/>
Expand Down Expand Up @@ -1173,6 +1181,7 @@ exports[`EuiSuperSelect props options are rendered when select is open 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value=""
/>
Expand Down Expand Up @@ -1329,6 +1338,7 @@ exports[`EuiSuperSelect props select component is rendered 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value=""
/>
Expand Down Expand Up @@ -1394,6 +1404,7 @@ exports[`EuiSuperSelect props valueSelected is rendered 1`] = `
class="euiPopover__anchor euiSuperSelect__popoverAnchor"
>
<input
invalid="false"
type="hidden"
value="2"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`EuiSuperSelectControl is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -64,6 +65,7 @@ Array [
exports[`EuiSuperSelectControl props compressed is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -123,6 +125,7 @@ Array [
exports[`EuiSuperSelectControl props disabled options are rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -182,6 +185,7 @@ Array [
exports[`EuiSuperSelectControl props empty value option is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -241,6 +245,7 @@ Array [
exports[`EuiSuperSelectControl props fullWidth is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -297,9 +302,70 @@ Array [
]
`;

exports[`EuiSuperSelectControl props isInvalid is rendered 1`] = `
Array [
<input
invalid="true"
type="hidden"
value=""
/>,
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<span
class="euiScreenReaderOnly"
id="generated-id"
>
Select an option: , is selected
</span>
<button
aria-haspopup="true"
aria-labelledby="undefined generated-id"
class="euiSuperSelectControl euiSuperSelectControl-isInvalid"
role="option"
type="button"
/>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<span
class="euiFormControlLayoutCustomIcon"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiFormControlLayoutCustomIcon__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
>
<defs>
<path
d="M13.069 5.157L8.384 9.768a.546.546 0 0 1-.768 0L2.93 5.158a.552.552 0 0 0-.771 0 .53.53 0 0 0 0 .759l4.684 4.61c.641.631 1.672.63 2.312 0l4.684-4.61a.53.53 0 0 0 0-.76.552.552 0 0 0-.771 0z"
id="arrow_down-a"
/>
</defs>
<use
fill-rule="nonzero"
href="#arrow_down-a"
/>
</svg>
</span>
</div>
</div>
</div>,
]
`;

exports[`EuiSuperSelectControl props isLoading is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value=""
/>,
Expand Down Expand Up @@ -362,6 +428,7 @@ Array [
exports[`EuiSuperSelectControl props value option is rendered 1`] = `
Array [
<input
invalid="false"
type="hidden"
value="1"
/>,
Expand Down
1 change: 1 addition & 0 deletions src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,6 @@ EuiSuperSelect.defaultProps = {
hasDividers: false,
fullWidth: false,
compressed: false,
isInvalid: false,
options: [],
};
3 changes: 2 additions & 1 deletion src/components/form/super_select/super_select_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const EuiSuperSelectControl = ({
name={name}
defaultValue={selectDefaultValue}
value={value}
invalid={isInvalid}
invalid={`${isInvalid}`}
snide marked this conversation as resolved.
Show resolved Hide resolved
/>

<EuiFormControlLayout
Expand Down Expand Up @@ -121,5 +121,6 @@ EuiSuperSelectControl.defaultProps = {
options: [],
fullWidth: false,
isLoading: false,
isInvalid: false,
compressed: false,
};
9 changes: 9 additions & 0 deletions src/components/form/super_select/super_select_control.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('EuiSuperSelectControl', () => {
.toMatchSnapshot();
});

test('isInvalid is rendered', () => {
const component = render(
<EuiSuperSelectControl isInvalid/>
);

expect(component)
.toMatchSnapshot();
});

test('disabled options are rendered', () => {
const component = render(
<EuiSuperSelectControl
Expand Down