Skip to content

Commit 11e8253

Browse files
authored
Merge pull request Expensify#67106 from mkzie2/mkzie2-issue/66705
fix: per diem amount section displays alpha numeric keypad
2 parents b62baff + f7ad7e0 commit 11e8253

7 files changed

Lines changed: 60 additions & 2 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,7 @@ const CONST = {
17861786
ASCII_CAPABLE: 'ascii-capable',
17871787
NUMBER_PAD: 'number-pad',
17881788
DECIMAL_PAD: 'decimal-pad',
1789+
NUMBERS_AND_PUNCTUATION: 'numbers-and-punctuation',
17891790
},
17901791

17911792
INPUT_MODE: {

src/components/AmountWithoutCurrencyInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, {useCallback, useMemo} from 'react';
22
import type {ForwardedRef} from 'react';
33
import useLocalize from '@hooks/useLocalize';
4+
import getAmountInputKeyboard from '@libs/getAmountInputKeyboard';
45
import {replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount} from '@libs/MoneyRequestUtils';
5-
import CONST from '@src/CONST';
66
import TextInput from './TextInput';
77
import type {BaseTextInputProps, BaseTextInputRef} from './TextInput/BaseTextInput/types';
88

@@ -57,6 +57,8 @@ function AmountWithoutCurrencyInput(
5757
},
5858
];
5959

60+
const {keyboardType, inputMode} = getAmountInputKeyboard(shouldAllowNegative);
61+
6062
return (
6163
<TextInput
6264
inputID={inputID}
@@ -67,7 +69,8 @@ function AmountWithoutCurrencyInput(
6769
accessibilityLabel={accessibilityLabel}
6870
role={role}
6971
ref={ref}
70-
keyboardType={!shouldAllowNegative ? CONST.KEYBOARD_TYPE.DECIMAL_PAD : undefined}
72+
keyboardType={keyboardType}
73+
inputMode={inputMode}
7174
type="mask"
7275
mask={shouldAllowNegative ? `[~][99999999]${separator}[09]` : `[09999999]${separator}[09]`}
7376
customNotations={customMask}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import CONST from '@src/CONST';
2+
import type GetAmountInputKeyboard from './type';
3+
4+
const getAmountInputKeyboard: GetAmountInputKeyboard = () => {
5+
return {
6+
keyboardType: CONST.KEYBOARD_TYPE.DECIMAL_PAD,
7+
inputMode: CONST.INPUT_MODE.DECIMAL,
8+
};
9+
};
10+
11+
export default getAmountInputKeyboard;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import CONST from '@src/CONST';
2+
import type GetAmountInputKeyboard from './type';
3+
4+
const getAmountInputKeyboard: GetAmountInputKeyboard = () => {
5+
return {
6+
keyboardType: CONST.KEYBOARD_TYPE.DECIMAL_PAD,
7+
inputMode: CONST.INPUT_MODE.DECIMAL,
8+
};
9+
};
10+
11+
export default getAmountInputKeyboard;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import CONST from '@src/CONST';
2+
import type GetAmountInputKeyboard from './type';
3+
4+
const getAmountInputKeyboard: GetAmountInputKeyboard = (shouldAllowNegative = false) => {
5+
return {
6+
keyboardType: shouldAllowNegative ? CONST.KEYBOARD_TYPE.NUMBERS_AND_PUNCTUATION : CONST.KEYBOARD_TYPE.DECIMAL_PAD,
7+
inputMode: shouldAllowNegative ? undefined : CONST.INPUT_MODE.DECIMAL,
8+
};
9+
};
10+
11+
export default getAmountInputKeyboard;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {isMobileIOS} from '@libs/Browser';
2+
import CONST from '@src/CONST';
3+
import type GetAmountInputKeyboard from './type';
4+
5+
const getAmountInputKeyboard: GetAmountInputKeyboard = (shouldAllowNegative = false) => {
6+
return {
7+
keyboardType: isMobileIOS() && shouldAllowNegative ? CONST.KEYBOARD_TYPE.NUMBERS_AND_PUNCTUATION : CONST.KEYBOARD_TYPE.DECIMAL_PAD,
8+
inputMode: isMobileIOS() && shouldAllowNegative ? undefined : CONST.INPUT_MODE.DECIMAL,
9+
};
10+
};
11+
12+
export default getAmountInputKeyboard;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type {ValueOf} from 'type-fest';
2+
import type CONST from '@src/CONST';
3+
4+
type GetAmountInputKeyboard = (shouldAllowNegative?: boolean) => {
5+
keyboardType: ValueOf<typeof CONST.KEYBOARD_TYPE> | undefined;
6+
inputMode: ValueOf<typeof CONST.INPUT_MODE> | undefined;
7+
};
8+
9+
export default GetAmountInputKeyboard;

0 commit comments

Comments
 (0)