Duolith docs

0106. autocomplete on fields, mapped to each platform's autofill

  • Status: Accepted (Mik, 16 Nov 2026)
  • Date: 2026-11-15
  • Decided by: domain E implementer (internal only)
  • Planning item: wave 5, autocomplete

Context

Sign-in and address forms are slow to fill on a phone. The browser, iOS and Android can all offer saved values, but each needs to be told what a field holds, in its own words.

Decision

<input> and <textarea> take autocomplete, one of the HTML autocomplete words the language lists (off, name, given-name, family-name, nickname, email, username, current-password, new-password, one-time-code, tel, street-address, address-line1, address-line2, address-level1, address-level2, postal-code, country, country-name, organization, organization-title, cc-name, cc-number, cc-exp, cc-exp-month, cc-exp-year, cc-csc, bday, url). Written as text, any other word is E0512; bound, its type is the same set (Autocomplete from @duolith/client).

  • Web: the autocomplete attribute.
  • iOS: text-content-type, a UITextContentType (current-password is password, one-time-code is oneTimeCode).
  • Android: autofill-hints, an androidx.autofill.HintConstants hint (one-time-code is smsOTPCode).

The kit's TextField takes an autocomplete prop and passes it on.

Alternatives considered

OptionWhy not
Platform words (textContentType) in markupThree spellings per field, two of them wrong on each platform
Infer from typetype="email" can be a username, a new address or a contact's address

Amendment: the shells, and the words Android cannot fill

Proposed (needs Mik), after the review of PR #36.

The first version said "a word one platform has no counterpart for gives it nothing", and no shell read either attribute, so autocomplete did nothing on a phone. Now:

  • Android: the shell depends on Lynx's xelement-input and registers DuolithInput (native/android/.../DuolithInput.kt) as the input element: a LynxUIInput whose autofill-hints prop (its setter generated by lynx-processor) calls the EditText's setAutofillHints with importantForAutofill YES, or sets NO for off. Each hint is checked against androidx.autofill.HintConstants (AutofillHints.kt, with a JVM test); one it does not know is logged and not sent.
  • iOS: the Podfile adds XElement and DuolithViewController registers DuolithInput (native/ios/Sources/DuolithShell/DuolithInput.swift) as the input UI: a LynxUIInput whose text-content-type prop sets the UITextField's textContentType (AutofillContentTypes.swift; iOS 17's card and birthday types only on iOS 17).
  • Words Android has no hint for (nickname, organization, organization-title, cc-name, url): written as text, the native build refuses them with E0519. This is the strictest rule that keeps every other word working: they still build for the web, which knows them, and every other word builds for both phones. A bound value cannot be known when the app is built; the engine reports it with a warning on Android when the field is drawn.
Option for those five wordsWhy not
Give Android nothing, silently (the first version)Against the rule that nothing is dropped silently
A warning in the native buildA warning lets the build pass with a field Android never fills
Refuse them everywhere (E0512)They work on the web and on iOS; a web-only app would lose them for nothing
Map them to a near hint (personName for cc-name)Android would offer the wrong saved value

Consequences

The shells read the two attributes from Lynx's input. Whether the autofill services then offer values is checked on a device (native/DEVICE-CHECKLIST.md).