Skip to content

Fix stopPropagation() and preventDefault() on cell events - #4217

Merged
nstepien merged 1 commit into
mainfrom
cell-event-propagation
Oct 21, 2026
Merged

nstepien merged 1 commit into
mainfrom
cell-event-propagation

Conversation

@nstepien

Copy link
Copy Markdown
Collaborator

Stacked on #3967.

Cell events inherit from React's event, but React's stopPropagation() and preventDefault() store their state on the object they're called on. When called on a cell event, they updated the cell event instead of React's event, so:

  • stopPropagation() in onCellClick, onCellKeyDown, or another cell event handler didn't stop React from calling parent handlers.
  • After preventDefault(), parent handlers saw isDefaultPrevented() return false.

The native event was still updated, so the browser's default action was prevented.

This predates #3967: cell events used to copy React's event, with the same result.

Cell events now call these two methods on React's event. The two new tests failed in all three browsers before the fix.

🤖 Generated with Claude Code

@nstepien
nstepien added this pull request to stack #4218 October 21, 2026 22:07
@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.36%. Comparing base (6f1f5cf) to head (2e39b26).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4217   +/-   ##
=======================================
  Coverage   98.35%   98.36%           
=======================================
  Files          45       45           
  Lines        1951     1955    +4     
  Branches      727      727           
=======================================
+ Hits         1919     1923    +4     
  Misses         32       32           
Files with missing lines Coverage Δ
src/utils/eventUtils.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from clarity to main October 21, 2026 23:04
Cell events inherit from React's event, but React's `stopPropagation()`
and `preventDefault()` store their state on the object they're called
on. Calling them on a cell event updated the cell event instead of
React's event, so React kept calling parent handlers after
`stopPropagation()`, and parent handlers saw `isDefaultPrevented()`
return `false` after `preventDefault()`.

Call them on React's event instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nstepien
nstepien force-pushed the cell-event-propagation branch from f5fc5a5 to 2e39b26 Compare October 21, 2026 23:05
@nstepien
nstepien merged commit a41d3b4 into main Oct 21, 2026
6 checks passed
@nstepien
nstepien deleted the cell-event-propagation branch October 21, 2026 23:24

@amanmahajan7 amanmahajan7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice catch!

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.

3 participants