Skip to content

Commit b5106a8

Browse files
dgladkovFacebook Github Bot 2
authored andcommitted
Implement TextInput.selectTextOnFocus for Android
Summary:Uses native Android `TextView.setSelectAllOnFocus` method. Triggers TextInput's `onSelectionChanged` event on focus as expected. Closes facebook/react-native#6654 Differential Revision: D3126354 Pulled By: mkonicek fb-gh-sync-id: faa64314c0ddc87296277ccd707f18effef8f407 fbshipit-source-id: faa64314c0ddc87296277ccd707f18effef8f407
1 parent 41b0160 commit b5106a8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Libraries/Components/TextInput/TextInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ var TextInput = React.createClass({
284284
clearTextOnFocus: PropTypes.bool,
285285
/**
286286
* If true, all text will automatically be selected on focus
287-
* @platform ios
288287
*/
289288
selectTextOnFocus: PropTypes.bool,
290289
/**
@@ -524,6 +523,7 @@ var TextInput = React.createClass({
524523
underlineColorAndroid={this.props.underlineColorAndroid}
525524
children={children}
526525
editable={this.props.editable}
526+
selectTextOnFocus={this.props.selectTextOnFocus}
527527
/>;
528528

529529
return (

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public void setSelectionColor(ReactEditText view, @Nullable Integer color) {
209209
}
210210
}
211211

212+
@ReactProp(name = "selectTextOnFocus", defaultBoolean = false)
213+
public void setSelectTextOnFocus(ReactEditText view, boolean selectTextOnFocus) {
214+
view.setSelectAllOnFocus(selectTextOnFocus);
215+
}
216+
212217
@ReactProp(name = ViewProps.COLOR, customType = "Color")
213218
public void setColor(ReactEditText view, @Nullable Integer color) {
214219
if (color == null) {

0 commit comments

Comments
 (0)