Environment
npm ls react-native-macos: 0.87.1
Using new arch
Steps to reproduce the bug
- Create a TextField with enableFocusRing=false
- Field is correctly displayed without a native macOS focus ring
- After some time. I've not been able to pin point why/how. The focus ring appears again.
Expected Behavior
Focus ring remains off, all the time. It seems the current code only calls setFocusRingType(...) when the prop changes. If AppKit or an internal control resets that later, React never reapplies it. I’m checking whether overriding the native getter is the safest fix for the controls used here.
Actual Behavior
No response
Reproducible Demo
No response
Additional context
This is probably not the patch you want, but AI fixed this for me with the following patches:
// Libraries/Text/TextInput/Singleline/RCTUITextField.mm
- (NSFocusRingType)focusRingType
{
return _enableFocusRing ? NSFocusRingTypeExterior : NSFocusRingTypeNone;
}
// and on setEnableFocusRing
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
if (_enableFocusRing != enableFocusRing) {
_enableFocusRing = enableFocusRing;
}
[super setFocusRingType:self.focusRingType];
[self setKeyboardFocusRingNeedsDisplayInRect:self.bounds];
}
and
// On React/Base/macos/RCTUIKit.m
// seems changes are replicated from RCTUITextField.mm
- (NSFocusRingType)focusRingType
{
return _enableFocusRing ? NSFocusRingTypeExterior : NSFocusRingTypeNone;
}
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
if (_enableFocusRing != enableFocusRing) {
_enableFocusRing = enableFocusRing;
}
[super setFocusRingType:self.focusRingType];
[self setKeyboardFocusRingNeedsDisplayInRect:self.bounds];
}
Environment
Steps to reproduce the bug
Expected Behavior
Focus ring remains off, all the time. It seems the current code only calls setFocusRingType(...) when the prop changes. If AppKit or an internal control resets that later, React never reapplies it. I’m checking whether overriding the native getter is the safest fix for the controls used here.
Actual Behavior
No response
Reproducible Demo
No response
Additional context
This is probably not the patch you want, but AI fixed this for me with the following patches:
and