Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: secure text become visible keep keyboard unchanged #9593

Merged
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ const CONST = {
PHONE_PAD: 'phone-pad',
NUMBER_PAD: 'number-pad',
DECIMAL_PAD: 'decimal-pad',
VISIBLE_PASSWORD: 'visible-password',
},

ATTACHMENT_SOURCE_ATTRIBUTE: 'data-expensify-source',
Expand Down
2 changes: 2 additions & 0 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as Expensicons from '../Icon/Expensicons';
import Text from '../Text';
import * as styleConst from './styleConst';
import * as StyleUtils from '../../styles/StyleUtils';
import getSecureEntryKeyboardType from '../../libs/getSecureEntryKeyboardType';

class BaseTextInput extends Component {
constructor(props) {
Expand Down Expand Up @@ -272,6 +273,7 @@ class BaseTextInput extends Component {
secureTextEntry={this.state.passwordHidden}
onPressOut={this.props.onPress}
showSoftInputOnFocus={!this.props.disableKeyboard}
keyboardType={getSecureEntryKeyboardType(this.props.keyboardType, this.props.secureTextEntry, this.state.passwordHidden)}
/>
{this.props.secureTextEntry && (
<Pressable
Expand Down
11 changes: 11 additions & 0 deletions src/libs/getSecureEntryKeyboardType/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CONST from '../../CONST';

/**
* Return visible-password keyboard type when secure text is visible on Android,
* otherwise return keyboardType passed as function parameter
* @param {String} keyboardType
* @param {Boolean} secureTextEntry
* @param {Boolean} passwordHidden
* @return {String}
*/
export default (keyboardType, secureTextEntry, passwordHidden) => (secureTextEntry && !passwordHidden ? CONST.KEYBOARD_TYPE.VISIBLE_PASSWORD : keyboardType);
6 changes: 6 additions & 0 deletions src/libs/getSecureEntryKeyboardType/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Return keyboardType passed as function parameter on Web/Desktop/iOS
* @param {String} keyboardType
* @return {String}
*/
export default keyboardType => keyboardType;