mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Summary: There's an inconsistency in autoCorrect's default state: - If you don't specify a value for autoCorrect, it defaults to on. - If you specify true/false for autoCorrect and later specify null, autoCorrect turns off. It should have reverted to its initial state of on. The reason for this discrepancy is that autoCorrect is exposed to JS as a boolean but it is actually an enum with three states in native: - UITextAutocorrectionTypeDefault (the default value) - UITextAutocorrectionTypeYes - UITextAutocorrectionTypeNo This is fixed by explicitly mapping JS null to UITextAutocorrectionTypeDefault. **Test plan (required)** Verified that switching `autoCorrect` between `true`, `false`, and `null` all work correctly in single line and multiline `TextInputs`. Adam Comella Microsoft Corp. Closes https://github.com/facebook/react-native/pull/11055 Differential Revision: D4226419 Pulled By: javache fbshipit-source-id: e3e5769a3aa537f00fb56ca4ae622ff4213481c5
23 lines
598 B
Objective-C
23 lines
598 B
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import "RCTConvert+Text.h"
|
|
|
|
@implementation RCTConvert (Text)
|
|
|
|
+ (UITextAutocorrectionType)UITextAutocorrectionType:(id)json
|
|
{
|
|
return
|
|
json == nil ? UITextAutocorrectionTypeDefault :
|
|
[RCTConvert BOOL:json] ? UITextAutocorrectionTypeYes :
|
|
UITextAutocorrectionTypeNo;
|
|
}
|
|
|
|
@end
|