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

[EuiFieldSearch] Fix padding when isClearable but no value yet #4089

Merged
merged 2 commits into from
Oct 1, 2020
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `29.3.0`.
**Bug fixes**

- Fixed `EuiFieldSearch` padding when `isClearable` but has no `value` ([#4089](https://github.com/elastic/eui/pull/4089))


## [`29.3.0`](https://github.com/elastic/eui/tree/v29.3.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`EuiFieldSearch props append is rendered 1`] = `
>
<eui-validatable-control>
<input
class="euiFieldSearch euiFieldText--inGroup euiFieldSearch-isClearable"
class="euiFieldSearch euiFieldText--inGroup"
type="search"
/>
</eui-validatable-control>
Expand All @@ -49,13 +49,47 @@ exports[`EuiFieldSearch props fullWidth is rendered 1`] = `
>
<eui-validatable-control>
<input
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable"
class="euiFieldSearch euiFieldSearch--fullWidth"
type="search"
/>
</eui-validatable-control>
</eui-form-control-layout>
`;

exports[`EuiFieldSearch props isClearable is accepted 1`] = `
<eui-form-control-layout
compressed="false"
fullwidth="false"
icon="search"
isloading="false"
>
<eui-validatable-control>
<input
class="euiFieldSearch"
type="search"
/>
</eui-validatable-control>
</eui-form-control-layout>
`;

exports[`EuiFieldSearch props isClearable is rendered when a value exists 1`] = `
<eui-form-control-layout
clear="[object Object]"
compressed="false"
fullwidth="false"
icon="search"
isloading="false"
>
<eui-validatable-control>
<input
class="euiFieldSearch euiFieldSearch-isClearable"
type="search"
value="Hello"
/>
</eui-validatable-control>
</eui-form-control-layout>
`;

exports[`EuiFieldSearch props isInvalid is rendered 1`] = `
<eui-form-control-layout
compressed="false"
Expand All @@ -67,7 +101,7 @@ exports[`EuiFieldSearch props isInvalid is rendered 1`] = `
isinvalid="true"
>
<input
class="euiFieldSearch euiFieldSearch-isClearable"
class="euiFieldSearch"
type="search"
/>
</eui-validatable-control>
Expand All @@ -83,7 +117,7 @@ exports[`EuiFieldSearch props isLoading is rendered 1`] = `
>
<eui-validatable-control>
<input
class="euiFieldSearch euiFieldSearch-isLoading euiFieldSearch-isClearable"
class="euiFieldSearch euiFieldSearch-isLoading"
type="search"
/>
</eui-validatable-control>
Expand All @@ -100,7 +134,7 @@ exports[`EuiFieldSearch props prepend is rendered 1`] = `
>
<eui-validatable-control>
<input
class="euiFieldSearch euiFieldText--inGroup euiFieldSearch-isClearable"
class="euiFieldSearch euiFieldText--inGroup"
type="search"
/>
</eui-validatable-control>
Expand Down
16 changes: 16 additions & 0 deletions src/components/form/field_search/field_search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ describe('EuiFieldSearch', () => {
expect(component).toMatchSnapshot();
});

describe('isClearable', () => {
test('is accepted', () => {
const component = render(<EuiFieldSearch isClearable />);

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

test('is rendered when a value exists', () => {
const component = render(
<EuiFieldSearch isClearable defaultValue="Hello" />
);

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

test('prepend is rendered', () => {
const component = render(<EuiFieldSearch prepend="Prepend" />);

Expand Down
2 changes: 1 addition & 1 deletion src/components/form/field_search/field_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class EuiFieldSearch extends Component<
'euiFieldSearch--compressed': compressed,
'euiFieldSearch-isLoading': isLoading,
'euiFieldText--inGroup': prepend || append,
'euiFieldSearch-isClearable': isClearable,
'euiFieldSearch-isClearable': isClearable && value,
},
className
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`EuiSelectableSearch is rendered 1`] = `
aria-label="aria-label"
aria-owns="list"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch testClass1 testClass2"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch testClass1 testClass2"
data-test-subj="test subject string"
role="combobox"
type="search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports[`EuiSelectableTemplateSitewide is rendered 1`] = `
aria-haspopup="listbox"
aria-label="aria-label"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch euiSelectableTemplateSitewide__search"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch euiSelectableTemplateSitewide__search"
placeholder="Search for anything..."
type="search"
value=""
Expand Down Expand Up @@ -68,7 +68,7 @@ exports[`EuiSelectableTemplateSitewide props popoverButton is not rendered with
aria-haspopup="listbox"
aria-label="Filter options"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch euiSelectableTemplateSitewide__search"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch euiSelectableTemplateSitewide__search"
placeholder="Search for anything..."
type="search"
value=""
Expand Down Expand Up @@ -150,7 +150,7 @@ exports[`EuiSelectableTemplateSitewide props popoverFooter is rendered 1`] = `
aria-haspopup="listbox"
aria-label="Filter options"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch euiSelectableTemplateSitewide__search"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch euiSelectableTemplateSitewide__search"
placeholder="Search for anything..."
type="search"
value=""
Expand Down Expand Up @@ -196,7 +196,7 @@ exports[`EuiSelectableTemplateSitewide props popoverProps is rendered 1`] = `
aria-haspopup="listbox"
aria-label="Filter options"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch euiSelectableTemplateSitewide__search"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch euiSelectableTemplateSitewide__search"
placeholder="Search for anything..."
type="search"
value=""
Expand Down Expand Up @@ -242,7 +242,7 @@ exports[`EuiSelectableTemplateSitewide props popoverTitle is rendered 1`] = `
aria-haspopup="listbox"
aria-label="Filter options"
autocomplete="off"
class="euiFieldSearch euiFieldSearch--fullWidth euiFieldSearch-isClearable euiSelectableSearch euiSelectableTemplateSitewide__search"
class="euiFieldSearch euiFieldSearch--fullWidth euiSelectableSearch euiSelectableTemplateSitewide__search"
placeholder="Search for anything..."
type="search"
value=""
Expand Down