Skip to content

[React Doctor] Marked 7 scroll and touchstart listeners as passive#432

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
react-doctor/2026-05-30/perf-passive-listeners
Open

[React Doctor] Marked 7 scroll and touchstart listeners as passive#432
github-actions[bot] wants to merge 1 commit into
mainfrom
react-doctor/2026-05-30/perf-passive-listeners

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 30, 2026

Marked 7 scroll and touchstart listeners as { passive: true } — unblocks main-thread scrolling on these handlers, none of which call preventDefault()

Browsers treat scroll/touchstart listeners as blocking by default — the compositor waits on each event until JS confirms it isn't going to call preventDefault(). All 7 handlers here are pure observers (re-measuring viewport, syncing positions, dismissing overlays); none gate scrolling. Flipping them to { passive: true } lets the browser scroll without that wait.

Changes



Note

Low Risk
Observer-only listeners with no preventDefault; passive flag is safe and limits scope to scroll performance.

Overview
Marks seven scroll and touchstart listeners as { passive: true } across the marketing site and react-grab so the browser can scroll without waiting on JS that never calls preventDefault().

Website: visualViewport scroll in the mobile demo (re-measure layout) and element scroll in Scrollable (custom scrollbar sync).

Library: visualViewport scroll on the selection label, toolbar, anchored dropdowns, and core overlay (viewport/version sync); touchstart on overlay dismiss is passive alongside existing capture, while mousedown stays non-passive where needed.

Behavior is unchanged—these handlers only measure, reposition, or dismiss.

Reviewed by Cursor Bugbot for commit ef5d264. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Marked 7 scroll and touchstart listeners as passive to remove main-thread blocking during scroll. Improves scroll responsiveness without behavior changes, since none of these handlers call preventDefault.

  • Performance
    • Added { passive: true } to visualViewport scroll handlers (toolbar, selection label, mobile demo, dropdown anchoring, core init).
    • Added { passive: true } to element scroll in Scrollable.
    • Kept existing options intact by merging with signal and { capture: true } (overlay dismiss touchstart).

Written for commit ef5d264. Summary will update on new commits.

Review in cubic

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added the react-doctor Opened by react-doctor label May 30, 2026
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment May 30, 2026 3:48pm
react-grab-website Ready Ready Preview, Comment May 30, 2026 3:48pm

Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestions:

  1. Event listener for touchstart is added with { capture: true, passive: true } but removed with only { capture: true }, causing the listener to not be properly removed
  1. The visualViewport scroll event listener is registered with { passive: true } but removed without the passive option, preventing proper cleanup and causing a memory leak
  1. Missing { passive: true } option in removeEventListener causes visualViewport scroll listener to not be properly removed, creating a memory leak
  1. addEventListener and removeEventListener options mismatch causes memory leak in event listener cleanup
  1. visualViewport scroll event listener is not properly removed due to mismatched addEventListener/removeEventListener options, causing a memory leak

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

react-doctor Opened by react-doctor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants