Skip to content

Commit 053c2b4

Browse files
authored
add enableFocusRing feature for TextInput component (#932)
1 parent 4aa5fd2 commit 053c2b4

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

Libraries/Components/TextInput/TextInput.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ function InternalTextInput(props: Props): React.Node {
11911191
accessibilityState={props.accessibilityState}
11921192
nativeID={props.nativeID}
11931193
testID={props.testID}
1194+
enableFocusRing={props.enableFocusRing} // TODO(macOS GH#774)
11941195
{...additionalTouchableProps}>
11951196
{textInput}
11961197
</TouchableWithoutFeedback>

Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputView.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ - (void)setUseSecureTextField:(BOOL)useSecureTextField {
8787
[self replaceSubview:previousTextField with:_backedTextInputView];
8888
}
8989
}
90+
91+
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
92+
[super setEnableFocusRing:enableFocusRing];
93+
if ([_backedTextInputView respondsToSelector:@selector(setEnableFocusRing:)]) {
94+
[_backedTextInputView setEnableFocusRing:enableFocusRing];
95+
}
96+
}
9097
#endif // ]TODO(macOS GH#774)
9198

9299
@end

Libraries/Text/TextInput/Singleline/RCTUITextField.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
5151
@property (nonatomic, assign) NSTextAlignment textAlignment;
5252
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
5353
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
54+
@property (nonatomic, assign) BOOL enableFocusRing;
5455
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
5556
@property (weak, nullable) id<RCTUITextFieldDelegate> delegate;
5657
#endif // ]TODO(macOS GH#774)

Libraries/Text/TextInput/Singleline/RCTUITextField.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ - (UIFont *)font
213213
return ((RCTUITextFieldCell*)self.cell).font;
214214
}
215215

216+
- (void)setEnableFocusRing:(BOOL)enableFocusRing {
217+
if (_enableFocusRing != enableFocusRing) {
218+
_enableFocusRing = enableFocusRing;
219+
}
220+
221+
if (enableFocusRing) {
222+
[self setFocusRingType:NSFocusRingTypeDefault];
223+
} else {
224+
[self setFocusRingType:NSFocusRingTypeNone];
225+
}
226+
}
227+
216228
#endif // ]TODO(macOS GH#774)
217229

218230
- (void)setPlaceholder:(NSString *)placeholder

0 commit comments

Comments
 (0)