mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 02:54:42 +00:00
8baaacb664
Summary: This PR makes sure that changing the `keyboardType` props of `<TextInput>` is reflected while the text field has focus. It is something that is also discusses in #13782. The workaround mentioned in that issue using `key` causes the TextInput to re-render itself which has some undesired side-effects. Fixes #13782 ```javascript export default class KeyboardTypeApp extends Component { state = { keyboardType: 'default' }; toggleKeyboardType = () => { this.setState({ keyboardType: this.state.keyboardType === 'default' ? 'numeric' : 'default' }); } render() { return ( <View style={{ padding: 40 }}> <TextInput autoFocus value="Press Toggle :)" keyboardType={this.state.keyboardType} /> <Button title="Toggle" onPress={this.toggleKeyboardType} /> </View> ); } } ``` ![video](https://user-images.githubusercontent.com/706368/39268429-3e331440-48d0-11e8-947c-7d334e3cec50.gif) <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [IOS] [ENHANCEMENT] [TextInput] - Keyboard layout now updates when changing `keyboardType` while it has focus <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes https://github.com/facebook/react-native/pull/19027 Differential Revision: D8416007 Pulled By: PeteTheHeat fbshipit-source-id: c4f89ab3dc0819bca52feddbc9c7a9f62fd96794
55 lines
1.9 KiB
Objective-C
55 lines
1.9 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <React/RCTView.h>
|
|
|
|
#import "RCTBackedTextInputDelegate.h"
|
|
#import "RCTBackedTextInputViewProtocol.h"
|
|
|
|
@class RCTBridge;
|
|
@class RCTEventDispatcher;
|
|
@class RCTTextAttributes;
|
|
@class RCTTextSelection;
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface RCTBaseTextInputView : RCTView <RCTBackedTextInputDelegate>
|
|
|
|
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
- (instancetype)initWithCoder:(NSCoder *)decoder NS_UNAVAILABLE;
|
|
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
|
|
|
|
@property (nonatomic, readonly) UIView<RCTBackedTextInputViewProtocol> *backedTextInputView;
|
|
|
|
@property (nonatomic, strong, nullable) RCTTextAttributes *textAttributes;
|
|
@property (nonatomic, assign) UIEdgeInsets reactPaddingInsets;
|
|
@property (nonatomic, assign) UIEdgeInsets reactBorderInsets;
|
|
|
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onContentSizeChange;
|
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
|
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChange;
|
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
|
|
@property (nonatomic, copy, nullable) RCTDirectEventBlock onScroll;
|
|
|
|
@property (nonatomic, assign) NSInteger mostRecentEventCount;
|
|
@property (nonatomic, assign) BOOL blurOnSubmit;
|
|
@property (nonatomic, assign) BOOL selectTextOnFocus;
|
|
@property (nonatomic, assign) BOOL clearTextOnFocus;
|
|
@property (nonatomic, copy) RCTTextSelection *selection;
|
|
@property (nonatomic, strong, nullable) NSNumber *maxLength;
|
|
@property (nonatomic, copy) NSAttributedString *attributedText;
|
|
@property (nonatomic, copy) NSString *inputAccessoryViewID;
|
|
@property (nonatomic, assign) UIKeyboardType keyboardType;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|