Skip to content

fix(0.81, fabric): force overlay scrollbar style in ScrollView#2908

Open
Saadnajmi wants to merge 1 commit into0.81-stablefrom
scrollbar-overlay-only-0.81
Open

fix(0.81, fabric): force overlay scrollbar style in ScrollView#2908
Saadnajmi wants to merge 1 commit into0.81-stablefrom
scrollbar-overlay-only-0.81

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

Summary

Backport of #2907 to 0.81-stable.

  • Force NSScrollerStyleOverlay on Fabric ScrollViews to fix layout overflow on first render
  • Remove autoresizingMask from documentView to prevent AppKit frame corruption
  • Fix scrollbar click hit testing (check NSScroller before content subviews)
  • Re-force overlay style when the system "Show scroll bars" preference changes at runtime

Why force overlay instead of supporting legacy scrollbars?

  1. Every other platform uses overlay scrollbars. iOS, Android, and web all render scrollbar indicators that float above content. Forcing overlay aligns macOS with every other React Native platform.

  2. Supporting legacy scrollbars required invasive changes to ReactCommon. The alternative required cached atomic values, custom shadow node constructors, and padding adjustments in the Yoga layout pass — a significant cross-platform change for a single-platform edge case.

  3. Apple themselves call non-overlay scrollbars "legacy." The API is literally NSScrollerStyleLegacy. Mac Catalyst doesn't even respect this preference (always uses overlay).

Test plan

  • Verified on macOS with "Show scroll bars: Always" — no overflow on first render
  • Verified switching system preference at runtime doesn't bring back legacy scrollbars
  • Verified scrollbar clicks work
  • Verified window resize doesn't cause overflow

Fixes #2857

🤖 Generated with Claude Code

@Saadnajmi Saadnajmi requested a review from a team as a code owner April 9, 2026 21:33
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 1843a23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Saadnajmi Saadnajmi changed the title fix(fabric,macos): force overlay scrollbar style in ScrollView [0.81 backport] fix(0.81, fabric): force overlay scrollbar style in ScrollView [0.81 backport] Apr 9, 2026
@Saadnajmi Saadnajmi changed the title fix(0.81, fabric): force overlay scrollbar style in ScrollView [0.81 backport] fix(0.81, fabric): force overlay scrollbar style in ScrollView Apr 9, 2026
Force NSScrollerStyleOverlay on Fabric ScrollViews to avoid layout
issues with legacy (always-visible) scrollbars. Legacy scrollbars sit
inside the NSScrollView frame and reduce the clip view's visible area,
which would require compensating padding in the Yoga shadow tree.
Overlay scrollers float above content, so no layout compensation is
needed.

Additional fixes:
- Remove autoresizingMask from documentView to prevent AppKit frame
  corruption during tile/resize
- Remove the layoutSubviews workaround (no longer needed without
  autoresizingMask)
- Add [_scrollView tile] after content size updates to re-evaluate
  scroller visibility
- Fix hit testing: check NSScroller before content subviews so
  scrollbar clicks aren't swallowed by full-width content views

Fixes #2857

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi force-pushed the scrollbar-overlay-only-0.81 branch from 9c2bb94 to 1843a23 Compare April 9, 2026 23:22
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