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

Update EuiFieldSearch to show a clear button when defaultValue is present #3958

Merged
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
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>
`;