Skip to content

Commit 731e9fe

Browse files
Saadnajmiclaude
andcommitted
fix(fabric): remove autoresizingMask on ScrollView documentView to fix Text overflow
On macOS, the _containerView (NSScrollView's documentView) had autoresizingMask set to FlexibleWidth | FlexibleHeight. This conflicts with React's explicit frame management: when AppKit's NSClipView resizes (e.g., during initial tile after mounting), autoresizing adds the clip view's size delta to the container's dimensions, inflating it well beyond the correct content size and producing massive horizontal and vertical overflow on first render. Resizing the window triggers a React re-layout that overwrites the corrupted frame, which is why the issue self-corrects. The fix removes the autoresizingMask so React's layout system (via updateState:) is the sole manager of the documentView's frame. This is consistent with the Paper architecture, which never set autoresizingMask on the documentView. Fixes #2857 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 70f3149 commit 731e9fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ - (instancetype)initWithFrame:(CGRect)frame
157157
#if !TARGET_OS_OSX // [macOS]
158158
[_scrollView addSubview:_containerView];
159159
#else // [macOS
160-
_containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
160+
// Do not set autoresizingMask on _containerView. On macOS, the _containerView serves as the
161+
// NSScrollView's documentView, and its frame directly determines the scrollable content area.
162+
// React's layout system (via updateState:) explicitly manages the _containerView's frame to
163+
// match the content bounding rect. Setting autoresizingMask causes AppKit's autoresizing to
164+
// resize the _containerView whenever the NSClipView resizes (e.g., on initial tile or window
165+
// resize), corrupting the frame that React set and producing massive overflow on first render.
161166
[_scrollView setDocumentView:_containerView];
162167
#endif // macOS]
163168

0 commit comments

Comments
 (0)