diff --git a/Examples/UIExplorer/TextInputExample.js b/Examples/UIExplorer/TextInputExample.js
index a32937fa4..922dd9607 100644
--- a/Examples/UIExplorer/TextInputExample.js
+++ b/Examples/UIExplorer/TextInputExample.js
@@ -99,12 +99,21 @@ var styles = StyleSheet.create({
fontSize: 13,
height: 50,
padding: 4,
+ marginBottom: 4,
},
multilineWithFontStyles: {
color: 'blue',
fontWeight: 'bold',
fontSize: 18,
fontFamily: 'Cochin',
+ height: 60,
+ },
+ multilineChild: {
+ width: 50,
+ height: 40,
+ position: 'absolute',
+ right: 5,
+ backgroundColor: 'red',
},
eventLabel: {
margin: 3,
@@ -351,14 +360,32 @@ exports.examples = [
+
+
+
+
)
}
diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js
index 9de1e15e9..c21184b7d 100644
--- a/Libraries/Components/TextInput/TextInput.js
+++ b/Libraries/Components/TextInput/TextInput.js
@@ -38,6 +38,7 @@ var returnKeyTypeConsts = RCTUIManager.UIReturnKeyType;
var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, {
autoCorrect: true,
autoCapitalize: true,
+ clearTextOnFocus: true,
color: true,
editable: true,
fontFamily: true,
@@ -48,6 +49,7 @@ var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, {
returnKeyType: true,
enablesReturnKeyAutomatically: true,
secureTextEntry: true,
+ selectTextOnFocus: true,
mostRecentEventCounter: true,
placeholder: true,
placeholderTextColor: true,
@@ -499,6 +501,8 @@ var TextInput = React.createClass({
autoCapitalize={autoCapitalize}
autoCorrect={this.props.autoCorrect}
clearButtonMode={clearButtonMode}
+ selectTextOnFocus={this.props.selectTextOnFocus}
+ clearTextOnFocus={this.props.clearTextOnFocus}
/>;
}
diff --git a/Libraries/Text/RCTTextView.h b/Libraries/Text/RCTTextView.h
index 742c81534..19f2fea39 100644
--- a/Libraries/Text/RCTTextView.h
+++ b/Libraries/Text/RCTTextView.h
@@ -17,6 +17,8 @@
@interface RCTTextView : RCTView
@property (nonatomic, assign) BOOL autoCorrect;
+@property (nonatomic, assign) BOOL clearTextOnFocus;
+@property (nonatomic, assign) BOOL selectTextOnFocus;
@property (nonatomic, assign) UIEdgeInsets contentInset;
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
@property (nonatomic, strong) UIColor *placeholderTextColor;
diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m
index a98bbc3ea..c5947f317 100644
--- a/Libraries/Text/RCTTextView.m
+++ b/Libraries/Text/RCTTextView.m
@@ -133,8 +133,24 @@
return _textView.autocorrectionType == UITextAutocorrectionTypeYes;
}
+- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
+{
+ if (_selectTextOnFocus) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [textView selectAll:nil];
+ });
+ }
+ return YES;
+}
+
- (void)textViewDidBeginEditing:(UITextView *)textView
{
+ if (_clearTextOnFocus) {
+ [_textView setText:@""];
+ _textView.text = @"";
+ [self _setPlaceholderVisibility];
+ }
+
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
reactTag:self.reactTag
text:textView.text];
@@ -159,14 +175,15 @@
- (BOOL)becomeFirstResponder
{
_jsRequestingFirstResponder = YES;
- BOOL result = [super becomeFirstResponder];
+ BOOL result = [_textView becomeFirstResponder];
_jsRequestingFirstResponder = NO;
return result;
}
- (BOOL)resignFirstResponder
{
- BOOL result = [super resignFirstResponder];
+ [super resignFirstResponder];
+ BOOL result = [_textView resignFirstResponder];
if (result) {
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeBlur
reactTag:self.reactTag
diff --git a/Libraries/Text/RCTTextViewManager.m b/Libraries/Text/RCTTextViewManager.m
index 5218544d2..570a51115 100644
--- a/Libraries/Text/RCTTextViewManager.m
+++ b/Libraries/Text/RCTTextViewManager.m
@@ -25,16 +25,17 @@ RCT_EXPORT_MODULE()
}
RCT_EXPORT_VIEW_PROPERTY(autoCorrect, BOOL)
+RCT_REMAP_VIEW_PROPERTY(editable, textView.editable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
RCT_EXPORT_VIEW_PROPERTY(placeholderTextColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
-RCT_REMAP_VIEW_PROPERTY(clearTextOnFocus, clearsOnBeginEditing, BOOL)
-RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
-RCT_EXPORT_VIEW_PROPERTY(returnKeyType, UIReturnKeyType)
-RCT_EXPORT_VIEW_PROPERTY(enablesReturnKeyAutomatically, BOOL)
-RCT_EXPORT_VIEW_PROPERTY(secureTextEntry, BOOL)
+RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
+RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
+RCT_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType)
+RCT_REMAP_VIEW_PROPERTY(returnKeyType, textView.returnKeyType, UIReturnKeyType)
+RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL)
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
-RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
+RCT_REMAP_VIEW_PROPERTY(autoCapitalize, textView.autocapitalizationType, UITextAutocapitalizationType)
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextView)
{
view.font = [RCTConvert UIFont:view.font withSize:json ?: @(defaultView.font.pointSize)];