Commit a054786
fix(fabric): force overlay scrollbar style in ScrollView (#2907)
## Summary
- 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. macOS is
the only platform where scrollbars can sit inside the frame and reduce
the visible content area. Forcing overlay aligns macOS behavior with
every other React Native platform.
2. **Supporting legacy scrollbars required invasive changes to
ReactCommon.** The alternative approach required adding cached atomic
values, custom shadow node constructors, and padding adjustments in the
Yoga layout pass at the `ScrollViewShadowNode` C++ layer — a significant
cross-platform change to support 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 system preference (it always uses overlay). SwiftUI does respect
it, but SwiftUI also has the advantage of proposing clip view size to
children — something React Native's layout system doesn't do.
## Test plan
- [x] Open RNTester on macOS with "Show scroll bars: Always" in System
Settings
- [x] Verify ScrollView content does not overflow on first render
- [x] Verify scrollbars appear as overlay style (thin, semi-transparent)
- [x] Verify switching system preference at runtime doesn't bring back
legacy scrollbars
- [x] Verify scrollbar clicks work (drag the scrollbar thumb)
- [x] Verify window resize doesn't cause content overflow
- [x] Test with "Show scroll bars: When scrolling" (default) — unchanged
behavior
Fixes #2857
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 4d114df commit a054786
File tree
1 file changed
+27
-21
lines changed- packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView
1 file changed
+27
-21
lines changedLines changed: 27 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
208 | 195 | | |
209 | 196 | | |
210 | 197 | | |
| |||
585 | 572 | | |
586 | 573 | | |
587 | 574 | | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
588 | 587 | | |
589 | 588 | | |
590 | 589 | | |
| |||
889 | 888 | | |
890 | 889 | | |
891 | 890 | | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
892 | 894 | | |
893 | 895 | | |
894 | 896 | | |
895 | 897 | | |
896 | 898 | | |
897 | 899 | | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
898 | 904 | | |
899 | 905 | | |
900 | 906 | | |
| |||
0 commit comments