Skip to content

RN parity: showSoftInputOnFocus property of <TextInput /> is not supported #2421

@zzz0108

Description

@zzz0108

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

In https://reactnative.dev/docs/textinput, there's the showSoftInputOnFocus property that will prevent the soft keyboard from showing when the field is focused, but react-native-web does not support this yet.

Expected behavior

showSoftInputOnFocus property of <TextInput /> works correctly

Steps to reproduce

  1. Create a TextInput with showSoftInputOnFocus=false
  2. Open mobile browser, click on the TextInput
  3. We still see the keyboard open, the keyboard should not open

Test case

https://codesandbox.io/s/runtime-paper-lgmxb3

Additional comments

Since react-native-web does not support showSoftInputOnFocus yet, we need to make an update to support it
In https://github.com/Expensify/react-native-web -> packages/react-native-web/src/exports/TextInput/index.js

const {
+    showSoftInputOnFocus = true
  } = props;
...
  switch (keyboardType) {
    case 'email-address':
      type = 'email';
      break;
    case 'number-pad':
    case 'numeric':
      inputMode = 'numeric';
      break;
    case 'decimal-pad':
      inputMode = 'decimal';
      break;
    case 'phone-pad':
      type = 'tel';
      break;
    case 'search':
    case 'web-search':
      type = 'search';
      break;
    case 'url':
      type = 'url';
      break;
    default:
      type = 'text';
  }

+  if (!showSoftInputOnFocus) {
+    inputMode = 'none';
+  }

I can open a PR for this once this issue proposal is accepted.
Thanks!
cc @necolas

Metadata

Metadata

Assignees

No one assigned

    Labels

    has: prSubject of a pull request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions