[ReactNative] Fix TextInput Focus issue

This commit is contained in:
Krzysztof Magiera 2015-07-31 10:49:29 -07:00
parent 53fb5b6cee
commit b807c51bbe
1 changed files with 19 additions and 2 deletions

View File

@ -15,6 +15,7 @@
*/
'use strict';
var Platform = require('Platform');
var RCTUIManager = require('NativeModules').UIManager;
var TextInputState = {
@ -39,7 +40,15 @@ var TextInputState = {
focusTextInput: function(textFieldID: ?number) {
if (this._currentlyFocusedID !== textFieldID && textFieldID !== null) {
this._currentlyFocusedID = textFieldID;
RCTUIManager.focus(textFieldID);
if (Platform.OS === 'ios') {
RCTUIManager.focus(textFieldID);
} else if (Platform.OS === 'android') {
RCTUIManager.dispatchViewManagerCommand(
textFieldID,
RCTUIManager.AndroidTextInput.Commands.focusTextInput,
null
);
}
}
},
@ -51,7 +60,15 @@ var TextInputState = {
blurTextInput: function(textFieldID: ?number) {
if (this._currentlyFocusedID === textFieldID && textFieldID !== null) {
this._currentlyFocusedID = null;
RCTUIManager.blur(textFieldID);
if (Platform.OS === 'ios') {
RCTUIManager.blur(textFieldID);
} else if (Platform.OS === 'android') {
RCTUIManager.dispatchViewManagerCommand(
textFieldID,
RCTUIManager.AndroidTextInput.Commands.blurTextInput,
null
);
}
}
}
};