Skip to content

Commit

Permalink
Merge pull request #9593 from b1tjoy/fix/9444-secure-text-visible-key…
Browse files Browse the repository at this point in the history
…board-unchange

fix: secure text become visible keep keyboard unchanged
  • Loading branch information
tgolen authored Jul 18, 2022
2 parents 1a101b3 + 4a88b27 commit c45e58f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
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;

0 comments on commit c45e58f

Please sign in to comment.