Skip to content

Commit 09bb94a

Browse files
CopilotSaadnajmi
andcommitted
Force Core Animation border rendering for TextInput on macOS by enabling clipsToBounds
Co-authored-by: Saadnajmi <6722175+Saadnajmi@users.noreply.github.com>
1 parent 2199b77 commit 09bb94a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,21 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
420420
{
421421
CGSize previousContentSize = _backedTextInputView.contentSize;
422422

423+
#if TARGET_OS_OSX // [macOS
424+
// On macOS, ensure proper border rendering by enabling clip to bounds
425+
// when borders are present. This forces Core Animation border rendering
426+
// which displays correctly with the native text field subview.
427+
const auto &props = static_cast<const TextInputProps &>(*_props);
428+
const auto borderMetrics = props.resolveBorderMetrics(layoutMetrics);
429+
BOOL hasBorder = borderMetrics.borderWidths.left > 0 || borderMetrics.borderWidths.right > 0 ||
430+
borderMetrics.borderWidths.top > 0 || borderMetrics.borderWidths.bottom > 0;
431+
if (hasBorder) {
432+
// Note: Setting clipsToBounds ensures Core Animation border rendering is used,
433+
// which properly displays with the native text field subview on macOS
434+
self.clipsToBounds = YES;
435+
}
436+
#endif // macOS]
437+
423438
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
424439

425440
#if TARGET_OS_OSX // [macOS

0 commit comments

Comments
 (0)