Skip to content

Commit e9f8381

Browse files
Pass grammarCheck to text input views for Mac (#1293)
1 parent d69fa5b commit e9f8381

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

Libraries/Components/TextInput/RCTTextInputViewConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const RCTTextInputViewConfig = {
141141
autoCapitalize: true,
142142
keyboardAppearance: true,
143143
passwordRules: true,
144+
grammarCheck: true, // TODO(macOS GH#774)
144145
spellCheck: true,
145146
selectTextOnFocus: true,
146147
text: true,

Libraries/Components/TextInput/TextInput.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ type IOSProps = $ReadOnly<{|
303303
*/
304304
scrollEnabled?: ?boolean,
305305

306+
// [TODO(macOS GH#774)
307+
/**
308+
* If `false`, disables grammar-check.
309+
* @platform macOS
310+
*/
311+
grammarCheck?: ?boolean,
312+
// ]TODO(macOS GH#774)
313+
306314
/**
307315
* If `false`, disables spell-check style (i.e. red underlines).
308316
* The default value is inherited from `autoCorrect`.

Libraries/Text/TextInput/RCTBaseTextInputViewManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ @implementation RCTBaseTextInputViewManager
4848
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) // TODO(macOS GH#774)
4949
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) // TODO(macOS GH#774)
5050
RCT_REMAP_OSX_VIEW_PROPERTY(selectionColor, backedTextInputView.selectionColor, UIColor) // TODO(macOS GH#774)
51+
RCT_REMAP_OSX_VIEW_PROPERTY(grammarCheck, backedTextInputView.grammarCheckingEnabled, BOOL) // TODO(macOS GH#774)
5152
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) // TODO(macOS GH#774)
5253
RCT_REMAP_OSX_VIEW_PROPERTY(spellCheck, backedTextInputView.continuousSpellCheckingEnabled, BOOL) // TODO(macOS GH#774)
5354
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) // TODO(macOS GH#774)

Libraries/Text/TextInput/Singleline/RCTUITextField.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
5555
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
5656
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
5757
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
58+
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
5859
@property (nonatomic, assign) BOOL enableFocusRing;
5960
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
6061
@property (weak, nullable) id<RCTUITextFieldDelegate> delegate;

Libraries/Text/TextInput/Singleline/RCTUITextField.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ @interface RCTUITextFieldCell : NSTextFieldCell
2727
@property (nonatomic, getter=isAutomaticTextReplacementEnabled) BOOL automaticTextReplacementEnabled;
2828
@property (nonatomic, getter=isAutomaticSpellingCorrectionEnabled) BOOL automaticSpellingCorrectionEnabled;
2929
@property (nonatomic, getter=isContinuousSpellCheckingEnabled) BOOL continuousSpellCheckingEnabled;
30+
@property (nonatomic, getter=isGrammarCheckingEnabled) BOOL grammarCheckingEnabled;
3031
@property (nonatomic, strong, nullable) RCTUIColor *selectionColor;
3132

3233
@end
@@ -72,6 +73,7 @@ - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj
7273
fieldEditor.automaticSpellingCorrectionEnabled = self.isAutomaticSpellingCorrectionEnabled;
7374
fieldEditor.automaticTextReplacementEnabled = self.isAutomaticTextReplacementEnabled;
7475
fieldEditor.continuousSpellCheckingEnabled = self.isContinuousSpellCheckingEnabled;
76+
fieldEditor.grammarCheckingEnabled = self.isGrammarCheckingEnabled;
7577
NSMutableDictionary *selectTextAttributes = fieldEditor.selectedTextAttributes.mutableCopy;
7678
selectTextAttributes[NSBackgroundColorAttributeName] = self.selectionColor ?: [NSColor selectedControlColor];
7779
fieldEditor.selectedTextAttributes = selectTextAttributes;
@@ -208,6 +210,16 @@ - (BOOL)isContinuousSpellCheckingEnabled
208210
return ((RCTUITextFieldCell*)self.cell).isContinuousSpellCheckingEnabled;
209211
}
210212

213+
- (void)setGrammarCheckingEnabled:(BOOL)grammarCheckingEnabled
214+
{
215+
((RCTUITextFieldCell*)self.cell).grammarCheckingEnabled = grammarCheckingEnabled;
216+
}
217+
218+
- (BOOL)isGrammarCheckingEnabled
219+
{
220+
return ((RCTUITextFieldCell*)self.cell).isGrammarCheckingEnabled;
221+
}
222+
211223
- (void)setSelectionColor:(RCTUIColor *)selectionColor // TODO(OSS Candidate ISS#2710739)
212224
{
213225
((RCTUITextFieldCell*)self.cell).selectionColor = selectionColor;

0 commit comments

Comments
 (0)