Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,4 @@ fix_*.patch
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md
# macOS]
packages/react-native-compatibility-check/dist/
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ - (instancetype)initWithFrame:(CGRect)frame
_didMoveToWindow = NO;
_originalTypingAttributes = [_backedTextInputView.typingAttributes copy];

#if TARGET_OS_OSX // [macOS
// Ensure the backing text view doesn't interfere with border rendering
// by making sure it doesn't draw outside its bounds
if (_backedTextInputView.layer) {
_backedTextInputView.layer.masksToBounds = YES;
}
#endif // macOS]

[self addSubview:_backedTextInputView];
#if TARGET_OS_IOS // [macOS] [visionOS]
[self initializeReturnKeyType];
Expand Down Expand Up @@ -413,6 +421,24 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
{
CGSize previousContentSize = _backedTextInputView.contentSize;

#if TARGET_OS_OSX // [macOS
// On macOS, ensure proper border rendering by enabling clip to bounds
// when borders are present. This forces Core Animation border rendering
// which displays correctly with the native text field subview.
const auto &props = static_cast<const TextInputProps &>(*_props);
const auto borderMetrics = props.resolveBorderMetrics(layoutMetrics);
BOOL hasBorder = borderMetrics.borderWidths.left > 0 || borderMetrics.borderWidths.right > 0 ||
borderMetrics.borderWidths.top > 0 || borderMetrics.borderWidths.bottom > 0;
if (hasBorder) {
// Note: Setting clipsToBounds ensures Core Animation border rendering is used,
// which properly displays with the native text field subview on macOS
self.clipsToBounds = YES;
} else {
// Reset clipsToBounds when no borders are present
self.clipsToBounds = NO;
}
#endif // macOS]

[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];

#if TARGET_OS_OSX // [macOS
Expand All @@ -439,6 +465,10 @@ - (void)prepareForRecycle
_ignoreNextTextInputCall = NO;
_didMoveToWindow = NO;
[_backedTextInputView resignFirstResponder];
#if TARGET_OS_OSX // [macOS
// Reset clipsToBounds to prevent state leakage in recycled components
self.clipsToBounds = NO;
#endif // macOS]
}

#pragma mark - RCTBackedTextInputDelegate
Expand Down