Skip to content

TextInput: map React Native's birthdate-* autoComplete values to HTML's bday-* tokens #2973

Open

Description

@ericpoulinnz

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

React Native's autoComplete prop includes birthdate-day, birthdate-month, birthdate-year and birthdate-full (iOS 17+ and Android). react-native-web passes autoComplete to the DOM unchanged, so the input renders autocomplete="birthdate-day". That isn't an HTML autofill token, and browsers ignore it. The HTML tokens are bday-day, bday-month, bday-year and bday.

React Native's types only accept its own names, so a cross-platform component can't pass the HTML tokens without a cast or a Platform branch.

Expected behavior

<input autocomplete="bday-day">, in the same way returnKeyType already becomes enterKeyHint and keyboardType becomes inputMode.

Steps to reproduce

<TextInput autoComplete="birthdate-day" inputMode="numeric" />

renders <input autocomplete="birthdate-day">.

Test case

N/A

Additional comments

Proposed fix

const htmlAutoComplete = {
  'birthdate-day': 'bday-day',
  'birthdate-full': 'bday',
  'birthdate-month': 'bday-month',
  'birthdate-year': 'bday-year'
};

// in TextInput
const autoCompleteValue = autoComplete || autoCompleteType || 'on';
supportedProps.autoComplete = htmlAutoComplete[autoCompleteValue] || autoCompleteValue;

React Native's Android-only names (name-given, name-family, password-new, sms-otp, tel-device, username-new) also have HTML equivalents and could share the same table.

Context

Environment: react-native-web 0.21.4, react-native 0.88.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions