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

Conversation

anishagg17
Copy link
Contributor

@anishagg17 anishagg17 commented May 5, 2020

Summary

Fixes: #3420

I noticed that onSearch was called twice because of its binding with the input element during componentDidMount function as well as onKeyUp function.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples
- [ ] Added or updated jest tests
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Checked for accessibility including keyboard-only and screenreader modes

  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@anishagg17 anishagg17 changed the title fixed double search issue Fixed double search issue with [EuiFieldSearch] May 5, 2020
@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3425/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this in IE11 and latest FF, Chrome, Safari, and Edge (for mac). Looks good, other than one additional edge case.

src/components/form/field_search/field_search.tsx Outdated Show resolved Hide resolved
@chandlerprall
Copy link
Contributor

jenkins test this

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tested locally across our supported browsers with incremental mode enabled and disabled, everything calls the onSearch callback once as expected/desired. Will merge on passing CI.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3425/

@anishagg17
Copy link
Contributor Author

anishagg17 commented May 6, 2020

22:43:34 Summary of all failing tests
22:43:34 FAIL src/components/context_menu/context_menu_panel.test.tsx
22:43:34   ● EuiContextMenuPanel › behavior › focus › is set on the first focusable element by default if there are no items and hasFocus is true
22:43:34 
22:43:34     expect(received).toBe(expected) // Object.is equality
22:43:34 
22:43:34     Expected: <body />
22:43:34     Received: <button data-test-subj="button" />
22:43:34 
22:43:34     Difference:
22:43:34 
22:43:34     - Expected
22:43:34     + Received
22:43:34 
22:43:34     - <body />
22:43:34     + <button
22:43:34     +   data-test-subj="button"
22:43:34     + />
22:43:34 
22:43:34       280 |         await tick(20);
22:43:34       281 | 
22:43:34     > 282 |         expect(findTestSubject(component, 'button').getDOMNode()).toBe(
22:43:34           |                                                                   ^
22:43:34       283 |           document.activeElement
22:43:34       284 |         );
22:43:34       285 |       });
22:43:34 
22:43:34       at toBe (src/components/context_menu/context_menu_panel.test.tsx:282:67)
22:43:34       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
22:43:34       at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:274:22)
22:43:34       at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
22:43:34       at asyncGeneratorStep (src/components/context_menu/context_menu_panel.test.tsx:27:103)
22:43:34       at _next (src/components/context_menu/context_menu_panel.test.tsx:29:194)

I think this test is not related to current changes in any way

@chandlerprall
Copy link
Contributor

That one's known to be flaky,

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3425/

@chandlerprall chandlerprall merged commit 81080bf into elastic:master May 6, 2020
@anishagg17 anishagg17 deleted the formsearch/double branch May 6, 2020 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiFieldSearch] onSearch trigger 2 time when press enter
3 participants