Skip to content

Commit

Permalink
Update EuiFieldSearch to show a clear button when defaultValue is pre…
Browse files Browse the repository at this point in the history
…sent (#3958)

* Fixed bug where EuiFieldSearch did not show a clear button when a defaultValue is present

* changelog
  • Loading branch information
chandlerprall authored Aug 24, 2020
1 parent 5d71d2f commit d406bc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fixed bug in `EuiBasicTable` not fully expanding tall rows (height > 1000px) ([#3855](https://github.com/elastic/eui/pull/3855))
- Added `regressionJob`, `outlierDetectionJob` and `classificationJob` icons to Machine Learning icon set, updated others. ([#3931](https://github.com/elastic/eui/pull/3931))
- Fixed bug in `EuiDataGrid` which sometimes prevented header cells from being focusabled ([#3943](https://github.com/elastic/eui/pull/3943))
- Fixed bug in `EuiFieldSearch` where a default value would not include the clear button ([#3958](https://github.com/elastic/eui/pull/3958))

## [`28.2.0`](https://github.com/elastic/eui/tree/v28.2.0)

Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/search_bar/controlled_search_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const loadTags = () => {
});
};

const initialQuery = EuiSearchBar.Query.MATCH_ALL;
const initialQuery = 'status:open';

export const ControlledSearchBar = () => {
const [query, setQuery] = useState(initialQuery);
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/field_search/field_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export class EuiFieldSearch extends Component<
};

state = {
value: this.props.value || '',
value:
this.props.value ||
(this.props.defaultValue ? `${this.props.defaultValue}` : ''),
};

inputElement: HTMLInputElement | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ exports[`EuiSelectableSearch props defaultValue 1`] = `
/>
</span>
</div>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<button
aria-label="Clear input"
class="euiFormControlLayoutClearButton"
type="button"
>
<div
class="euiFormControlLayoutClearButton__icon"
data-euiicon-type="cross"
/>
</button>
</div>
</div>
</div>
`;

0 comments on commit d406bc6

Please sign in to comment.