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

Fixed double search issue with [EuiFieldSearch] #3425

Merged
merged 4 commits into from
May 6, 2020
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 @@ -13,6 +13,7 @@

**Bug Fixes**

- Fixed `EuiFieldSearch` to trigger `onSearch` single time instead of two times ([#3425](https://github.com/elastic/eui/pull/3425))
- Fixed `EuiBasicTable` item selection when `id` is `0` ([#3417](https://github.com/elastic/eui/pull/3417))
- Fixed `EuiNavDrawer` not closing on outside click after being unlocked ([#3415](https://github.com/elastic/eui/pull/3415))
- Fixed `EuiBadge` `iconOnClick` props makes badge text clickable ([#3392](https://github.com/elastic/eui/pull/3392))
Expand Down
5 changes: 2 additions & 3 deletions src/components/form/field_search/field_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import React, { Component, InputHTMLAttributes, KeyboardEvent } from 'react';
import classNames from 'classnames';
import { Browser } from '../../../services/browser';
import { ENTER } from '../../../services/key_codes';
import { CommonProps } from '../../common';

import {
Expand Down Expand Up @@ -100,7 +99,7 @@ export class EuiFieldSearch extends Component<
if (Browser.isEventSupported('search', this.inputElement)) {
const onSearch = (event?: Event) => {
if (this.props.onSearch) {
if (!event || !event.target) return;
if (!event || !event.target || event.defaultPrevented) return;
this.props.onSearch((event.target as HTMLInputElement).value);
}
};
Expand Down Expand Up @@ -187,7 +186,7 @@ export class EuiFieldSearch extends Component<
return;
}
}
if (onSearch && (incremental || event.keyCode === ENTER)) {
if (onSearch && incremental) {
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
onSearch((event.target as HTMLInputElement).value);
}
};
Expand Down