Commit e395913
fix(0.81, fabric): force overlay scrollbar style in ScrollView (#2908)
## 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
- [x] Verified on macOS with "Show scroll bars: Always" — no overflow on
first render
- [x] Verified switching system preference at runtime doesn't bring back
legacy scrollbars
- [x] Verified scrollbar clicks work
- [x] Verified window resize doesn't cause overflow
Fixes #2857
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 764c692 commit e395913
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