Skip to content

[EuiButtonGroup] Ensure onChange is called only once - #5033

Merged
thompsongl merged 3 commits into
elastic:masterfrom
thompsongl:4691-buttongroup
Aug 17, 2021
Merged

thompsongl merged 3 commits into
elastic:masterfrom
thompsongl:4691-buttongroup

Conversation

@thompsongl

@thompsongl thompsongl commented Aug 16, 2021 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4961, in which an EuiButtonGroup with type=single would fire the onChange callback twice for click events.

The fix is to remove the onClick handler for type=single groups because a label click will automatically call the input element's onChange handler.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile

  • Checked in Chrome, Safari, Edge, and Firefox

- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for the any docs 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

@thompsongl
thompsongl requested a review from cee-chen August 16, 2021 19:16
@thompsongl

Copy link
Copy Markdown
Contributor Author

ERROR: Failed to set up Chromium r818858! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.

jenkins test this

@kibanamachine

Copy link
Copy Markdown
Contributor

@cee-chen cee-chen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

QA'd locally in Kibana and against an Enterprise Search branch (that also reported this issue) and can confirm onChange is now only firing once. Thanks a million Greg!

One non-blocking comment on this PR - it always gives me a small amount of concern when I see a bug fix or functional change go in without a corresponding unit/jest test written - it might be nice someday to see a spec file written for button_group_button!

@thompsongl

Copy link
Copy Markdown
Contributor Author

it always gives me a small amount of concern when I see a bug fix or functional change go in without a corresponding unit/jest test written

Agreed. We're limited by enzyme here, though, because there's no way (that I've found) to test the <label> click ➡️ <input> onChange path. All click event simulation/dispatch relies on onClick, which isn't present on the case we're fixing here. Hopefully this is something that cypress, etc., can help with.

@kibanamachine

Copy link
Copy Markdown
Contributor

@cee-chen

Copy link
Copy Markdown
Contributor

Ahh gotcha! Huge thanks for the explanation, I hadn't grokked the code deeply enough to realize that was what was happening!

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.

[EuiButtonGroup] multiple events being fired per click

3 participants