fix(CardHorizontal): prevent duplicate button clicks - #1185
Conversation
🦋 Changeset detectedLatest commit: b12e986 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
🟢 Approval recommended
The event-propagation fix is targeted and is backed by regression tests covering the reported double-invocation behavior.
Pull request overview
This PR prevents duplicate click handling in CardHorizontal when the nested info button is present by stopping event bubbling from the button to the card container, and adds regression tests plus a patch changeset.
Changes:
- Add a dedicated
handleButtonClickthat callsstopPropagation()before delegating to the existing click handler. - Add tests asserting
onButtonClickandwindow.openare each invoked exactly once when clicking the inner button. - Add a patch changeset documenting the fix.
File summaries
| File | Description |
|---|---|
| src/components/CardHorizontal/CardHorizontal.tsx | Stops nested button click events from bubbling to the card, preventing duplicate handling. |
| src/components/CardHorizontal/CardHorizontal.test.tsx | Adds regression tests for single-invocation behavior on inner button clicks. |
| .changeset/fix-card-horizontal-button-bubbling.md | Records the fix as a patch release entry. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi @fallintoplace , thank you for contribution! LGTM, |
dad8872 to
b12e986
Compare
|
note: this will close #998 |
What changed
onClickhandler, including whenonClickis passed through...propsWhy
When a CardHorizontal has an info button, clicking it also triggers the card handler. This could call the callback and open the URL twice.
Checks