diff --git a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js index 1f3ab24ad..59e5cdcb8 100644 --- a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js +++ b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js @@ -165,10 +165,22 @@ describe('components/TextInput', () => { expect(input.type).toEqual('email'); }); + test('value "decimal-pad"', () => { + const { container } = render(); + const input = findInput(container); + expect(input.inputMode).toEqual('decimal'); + }); + + test('value "number-pad"', () => { + const { container } = render(); + const input = findInput(container); + expect(input.inputMode).toEqual('numeric'); + }); + test('value "numeric"', () => { const { container } = render(); const input = findInput(container); - expect(input.type).toEqual('number'); + expect(input.inputMode).toEqual('numeric'); }); test('value "phone-pad"', () => { diff --git a/packages/react-native-web/src/exports/TextInput/index.js b/packages/react-native-web/src/exports/TextInput/index.js index 83802792e..b0f2cf101 100644 --- a/packages/react-native-web/src/exports/TextInput/index.js +++ b/packages/react-native-web/src/exports/TextInput/index.js @@ -155,6 +155,7 @@ const TextInput = forwardRef((props, forwardedRef) => { } = props; let type; + let inputMode; switch (keyboardType) { case 'email-address': @@ -162,7 +163,10 @@ const TextInput = forwardRef((props, forwardedRef) => { break; case 'number-pad': case 'numeric': - type = 'number'; + inputMode = 'numeric'; + break; + case 'decimal-pad': + inputMode = 'decimal'; break; case 'phone-pad': type = 'tel'; @@ -368,6 +372,7 @@ const TextInput = forwardRef((props, forwardedRef) => { supportedProps.spellCheck = spellCheck != null ? spellCheck : autoCorrect; supportedProps.style = style; supportedProps.type = multiline ? undefined : type; + supportedProps.inputMode = inputMode; usePlatformMethods(hostRef, supportedProps);