-
Notifications
You must be signed in to change notification settings - Fork 861
[EuiCheckableCard] Fix onChange handler being invoked twice #8786
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
[EuiCheckableCard] Fix onChange handler being invoked twice #8786
Conversation
packages/eui/src/components/card/checkable_card/checkable_card.stories.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🟢 It works as expected, thanks for fixing this so quickly, @mgadewoll!
Non-blocking suggestion:
Let's update our checkable example in the docs to use prevValue => !prevValue to promote React best practices.
packages/website/docs/components/containers/card.mdx:366
onChange={(prevValue) => setCheckbox(!prevValue)}
weronikaolejniczak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I checked the staging link and it is not working as expected. Digging in...
Screen.Recording.2025-06-12.at.19.39.59.mov
@weronikaolejniczak You have a small mistake in your code update, that's why it doesn't work 🙂 Screen.Recording.2025-06-12.at.19.52.59.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgadewoll The issue was not even that because I did this screen just to send it here, must've typoed 😄 It's that I was reviewing prod and not the staging link. Late PR reviewing 🫠
I reviewed again today and it works as expected both locally in Storybook and in staging docs 👍🏻
20c6835 to
5bd67b7
Compare
ℹ️ Updated the docs example in 5bd67b7 |
💚 Build SucceededHistory
cc @mgadewoll |
💚 Build Succeeded
History
cc @mgadewoll |
`103.0.0` ⏩ `103.1.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Changes - **EuiDataGrid** now takes an `onFullScreenChange` callback - An accessibility fix in **EuiComboBox** - 3 bug fixes ## Package updates ### `@elastic/eui` ## [`v103.1.0`](https://github.com/elastic/eui/releases/v103.1.0) - Added `onFullScreenChange` prop to `EuiDataGrid` to handle changes when the component enters or exits fullscreen mode ([#8765](elastic/eui#8765)) **Bug fixes** - Fixed `onChange` being triggered twice when the checkbox in `EuiCheckableCard` is clicked ([#8786](elastic/eui#8786)) - Fixed a circular import on the legacy Amsterdam theme that would cause the theme usage to break ([#8780](elastic/eui#8780)) - Fixed high contrast theme token overrides not being applied ([#8742](elastic/eui#8742)) **Accessibility** - Fixed form errors not being read by screen readers for `EuiComboBox` inside of `EuiFormRow` ([#8798](elastic/eui#8798)) <!--ONMERGE {"backportTargets":["8.19","9.0"]} ONMERGE-->
`103.0.0` ⏩ `103.1.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Changes - **EuiDataGrid** now takes an `onFullScreenChange` callback - An accessibility fix in **EuiComboBox** - 3 bug fixes ## Package updates ### `@elastic/eui` ## [`v103.1.0`](https://github.com/elastic/eui/releases/v103.1.0) - Added `onFullScreenChange` prop to `EuiDataGrid` to handle changes when the component enters or exits fullscreen mode ([elastic#8765](elastic/eui#8765)) **Bug fixes** - Fixed `onChange` being triggered twice when the checkbox in `EuiCheckableCard` is clicked ([elastic#8786](elastic/eui#8786)) - Fixed a circular import on the legacy Amsterdam theme that would cause the theme usage to break ([elastic#8780](elastic/eui#8780)) - Fixed high contrast theme token overrides not being applied ([elastic#8742](elastic/eui#8742)) **Accessibility** - Fixed form errors not being read by screen readers for `EuiComboBox` inside of `EuiFormRow` ([elastic#8798](elastic/eui#8798)) <!--ONMERGE {"backportTargets":["8.19","9.0"]} ONMERGE--> (cherry picked from commit b0d46f7) # Conflicts: # package.json # yarn.lock

Summary
closes #8782
Why are we making this change?
This PR fixes an unexpected behavior where the
onChangeevent would be triggered twice on click of the checkbox withinEuiCheckableCard. This would result in the checkbox being unchecked instead of checked.This was due to the wrapper having a separate click handler to enlarge the clickable area.
The fix applied is to only trigger the wrapper click handler if the wrapper is clicked, not the checkbox.
Screenshots
Scenario: After a single click on the checkbox:
before: checkbox is unchecked
after: checkbox is checked
QA
e.targetincheckable_card.tsxand confirm that previously the checkbox is not checked on a single clickGeneral checklist
Checked in both light and dark modesChecked in both MacOS and Windows high contrast modesChecked in mobileChecked for accessibility including keyboard-only and screenreader modesAdded documentationProps have proper autodocs (using@defaultif default values are missing) and playground togglesChecked Code Sandbox works for any docs examplesUpdated visual regression testsIf applicable, added the breaking change issue label (and filled out the breaking change checklist)If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)