Skip to content

Commit

Permalink
Add getReturnKeyType function
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed Oct 18, 2023
1 parent bd3e4f4 commit 43eb00d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as StyleUtils from '../../styles/StyleUtils';
import variables from '../../styles/variables';
import Checkbox from '../Checkbox';
import getSecureEntryKeyboardType from '../../libs/getSecureEntryKeyboardType';
import getReturnKeyType from '../../libs/getReturnKeyType';
import CONST from '../../CONST';
import FormHelpMessage from '../FormHelpMessage';
import isInputAutoFilled from '../../libs/isInputAutoFilled';
Expand Down Expand Up @@ -355,6 +356,7 @@ function BaseTextInput(props) {
secureTextEntry={passwordHidden}
onPressOut={props.onPress}
showSoftInputOnFocus={!props.disableKeyboard}
returnKeyType={getReturnKeyType(props.returnKeyType, props.keyboardType)}
keyboardType={getSecureEntryKeyboardType(props.keyboardType, props.secureTextEntry, passwordHidden)}
value={props.value}
selection={props.selection}
Expand Down
16 changes: 16 additions & 0 deletions src/libs/getReturnKeyType/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import CONST from '../../CONST';
import GetReturnKeyType from './types';

/**
* Return returnKeyType passed as function parameter on Android
* Due to the fact that in the Android browser some keyboardTypes change the confirmation icon and ignore keyboardType, the ability to change the confirmation icon in the Android app to the one used in the browser has been added
*/
const getReturnKeyType: GetReturnKeyType = (returnKeyType, keyboardType) => {
if (keyboardType === CONST.KEYBOARD_TYPE.URL || keyboardType === CONST.KEYBOARD_TYPE.EMAIL_ADDRESS) {
return 'go';
}

return returnKeyType;
};

export default getReturnKeyType;
8 changes: 8 additions & 0 deletions src/libs/getReturnKeyType/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import GetReturnKeyType from './types';

/**
* Return returnKeyType passed as function parameter on Web/Desktop/iOS
*/
const getReturnKeyType: GetReturnKeyType = (returnKeyType) => returnKeyType;

export default getReturnKeyType;
3 changes: 3 additions & 0 deletions src/libs/getReturnKeyType/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type GetReturnKeyType = (returnKeyType: string, keyboardType: string) => string;

export default GetReturnKeyType;
4 changes: 1 addition & 3 deletions src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import Log from '../../../libs/Log';
import withNavigationFocus, {withNavigationFocusPropTypes} from '../../../components/withNavigationFocus';
import usePrevious from '../../../hooks/usePrevious';
import * as MemoryOnlyKeys from '../../../libs/actions/MemoryOnlyKeys/MemoryOnlyKeys';
import getPlatform from '../../../libs/getPlatform';

const propTypes = {
/** Should we dismiss the keyboard when transitioning away from the page? */
Expand Down Expand Up @@ -201,7 +200,6 @@ function LoginForm(props) {
const formErrorText = useMemo(() => (formError ? translate(formError) : ''), [formError, translate]);
const serverErrorText = useMemo(() => ErrorUtils.getLatestErrorMessage(props.account), [props.account]);
const hasError = !_.isEmpty(serverErrorText);
const returnKeyType = getPlatform() === CONST.PLATFORM.ANDROID ? 'go' : 'done';

return (
<>
Expand All @@ -215,7 +213,7 @@ function LoginForm(props) {
accessibilityLabel={translate('loginForm.phoneOrEmail')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
value={login}
returnKeyType={returnKeyType}
returnKeyType="done"
autoCompleteType="username"
textContentType="username"
nativeID="username"
Expand Down

0 comments on commit 43eb00d

Please sign in to comment.