Skip to content

fix: deprecate bubbling of direct events in fireEvent - #1941

Merged
mdjastrzebski merged 18 commits into
mainfrom
fix/non-bubbling-events
Oct 8, 2026
Merged

mdjastrzebski merged 18 commits into
mainfrom
fix/non-bubbling-events

Conversation

@mdjastrzebski

@mdjastrzebski mdjastrzebski commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

React Native delivers direct events (e.g. ScrollView scroll, Image load, layout) only to the emitting element, but fireEvent bubbles them. This PR deprecates that:

  • fireEvent warns when a direct event bubbles to an ancestor that emits it. Bubbling stops in the next major.
  • Direct events depend on the host element type (isDirectEvent()). Composite handlers count as being on the composite's root host element.
  • fireEvent.layout() shows the intended behavior (no bubbling). fireEvent(element, 'layout') now bubbles with the warning, for compatibility.

Also fixes undefined fields in fireEvent.layout() and renames the internal EventName type to EventType.

Test plan

@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.56%. Comparing base (b80a762) to head (3c02ab3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1941      +/-   ##
==========================================
+ Coverage   98.36%   98.56%   +0.20%     
==========================================
  Files          87       87              
  Lines        1714     1744      +30     
  Branches      449      481      +32     
==========================================
+ Hits         1686     1719      +33     
+ Misses         26       24       -2     
+ Partials        2        1       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@mdjastrzebski
mdjastrzebski force-pushed the fix/non-bubbling-events branch from cad6c61 to 28015f0 Compare October 7, 2026 13:23
@mdjastrzebski mdjastrzebski changed the title fix: properly handle non-bubbling events fix: deprecate bubbling of direct events in fireEvent Oct 8, 2026
@mdjastrzebski
mdjastrzebski merged commit 7e25db3 into main Oct 8, 2026
40 checks passed
@mdjastrzebski
mdjastrzebski deleted the fix/non-bubbling-events branch October 8, 2026 08:43
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.

1 participant