Skip to content

fix(0.81, scrollview): ScrollView layout with legacy (always-visible) scrollbars#2902

Closed
microsoft-react-native-sdk[bot] wants to merge 2 commits into0.81-stablefrom
0.81/scrollbar-insets
Closed

fix(0.81, scrollview): ScrollView layout with legacy (always-visible) scrollbars#2902
microsoft-react-native-sdk[bot] wants to merge 2 commits into0.81-stablefrom
0.81/scrollbar-insets

Conversation

@microsoft-react-native-sdk
Copy link
Copy Markdown

Summary

Backport of #2883 to 0.81-stable.

Test Plan

Same as #2883.

Saadnajmi and others added 2 commits April 9, 2026 02:18
… (Fabric)

On macOS, legacy scrollbars sit inside the NSScrollView frame and reduce
the NSClipView's visible area. React's layout system measures children
against the full frame, causing content to overflow behind the scrollbar.

Following the pattern from facebook#53247 (Switch), this fix
reads the scrollbar width synchronously during the Yoga layout pass via a
cached atomic value — no state round-trip, so the first layout is
immediately correct.

Key changes:
- Add ScrollViewShadowNode::setSystemScrollbarWidth() / getSystemScrollbarWidth()
  backed by a static atomic, called from native code at class load time
- applyScrollbarPadding() reads the cached value directly (not from state)
- Remove scrollbarTrailingWidth/scrollbarBottomHeight from ScrollViewState
- Remove autoresizingMask from documentView (prevents AppKit frame corruption)
- Move NSScroller hit test check before subview loop (fixes scrollbar clicks)
- Observe NSPreferredScrollerStyleDidChangeNotification for runtime changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Apply paddingEnd on the ScrollView's shadow node to account for legacy
scrollbar width, matching the Fabric approach. A new RCTScrollViewShadowView
(defined inline in RCTScrollViewManager.m) reads +[NSScroller
preferredScrollerStyle] and +scrollerWidthForControlSize: directly
during layoutWithMetrics: — these are thread-safe class methods, so no
localData round-trip is needed.

Key changes:
- Add RCTScrollViewShadowView with paddingEnd for scrollbar width
- Revert RCTScrollContentShadowView to stock (only RTL fix remains)
- Delete RCTScrollContentLocalData files (no longer used)
- Update preferredScrollerStyleDidChange: in RCTScrollView to re-tile
  and trigger content size update on system preference changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 764a40c

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 marked this pull request as draft April 9, 2026 02:28
@Saadnajmi Saadnajmi closed this Apr 9, 2026
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