Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another section is needed for autofill information #63170

Open
nturgut opened this issue Aug 7, 2020 · 5 comments
Open

Another section is needed for autofill information #63170

nturgut opened this issue Aug 7, 2020 · 5 comments
Labels
a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@nturgut
Copy link
Contributor

nturgut commented Aug 7, 2020

Browser can use a section information on the autofill forms.

Although this is not mandatory, Safari Desktop, uses labels such as shipping in front of the address related fields, otherwise even though the address is visible in the saved forms information, it is not getting re-filled.

An example html form should looks like this:

<form method="post" action="#" id="usrForm">
  <input type="text" name="given-name" id="given-name" autocomplete="given-name">
  <input type="text" name="family-name" id="family-name" autocomplete="family-name">
  <input type="text" name="organization-title" id="organization-title" autocomplete="organization-title">
  <input type="text" name="organization" id="organization" autocomplete="organization">
  <input type="text" name="address-line1" id="address-line1" autocomplete="shipping address-line1">
  <input type="text" name="address-line2" id="address-line2" autocomplete="shipping address-line2">
  <input type="text" name="country" id="country" autocomplete="shipping country">
  <input type="text" name="country-name" id="country-name" autocomplete="shipping country-name">
  <input type="text" name="postal-code" id="postal-code" autocomplete="shipping postal-code">
  <input type="submit" value="Submit" name="submit" id="submit">
</form>

As temporary solution we can add shipping in front of all address related fields for Safari Desktop (code location)

  void applyToDomElement(html.HtmlElement domElement,
      {bool focusedElement = false}) {
    domElement.id = hint;
    if (domElement is html.InputElement) {
      html.InputElement element = domElement;
      element.name = hint;
      element.id = hint;
      if(hint.contains('address') || hint.contains('country') || hint.contains('postal')) {
        element.autocomplete = 'shipping $hint';
      } else {
        element.autocomplete = hint;
      }
      if (hint.contains('password')) {
        element.type = 'password';
      } else {
        element.type = 'text';
      }
    } else if (domElement is html.TextAreaElement) {
      html.TextAreaElement element = domElement;
      element.name = hint;
      element.id = hint;
      element.setAttribute('autocomplete', hint);
    }
  }

A long term solution would be to being able to add these section names to autofill hint. For example 'shipping' 'billing' for address, or 'home', 'work' to phone number.

@nturgut
Copy link
Contributor Author

nturgut commented Aug 7, 2020

/cc @LongCatIsLooong assigning to framework first to see if we can get the long term solution out.

@nturgut nturgut added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Aug 7, 2020
@nturgut nturgut changed the title [web] safari desktop needs additional labels to fill address fields Another section is needed for autofill information Aug 7, 2020
@LongCatIsLooong
Copy link
Contributor

From the looks of it (https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), the section is just another hint string? autofillHints is already a sorted collection of strings, I think we just have to update the API docs and slightly change the web implementation?

@nturgut
Copy link
Contributor Author

nturgut commented Aug 7, 2020

It's not only a two word hint. For example this is how an element should look like:

<input type="text" name="address-line1" id="address-line1" autocomplete="shipping address-line1">

address-line-1 is the auotfill hint. Autocomplete argument also uses a section.

@LongCatIsLooong
Copy link
Contributor

If I specify the hints for a TextField like this

TextField(
  ...
  autofillHints: <String>['shipping', 'address-line1'],
)

would the above work?

@nturgut
Copy link
Contributor Author

nturgut commented Aug 18, 2020

If we put a rule such as, all the autofill-hints will be applied to autocomplete and the last one will be applied to other fields so the result looks like this, it might be possible.

<input type="text" name="address-line1" id="address-line1" autocomplete="shipping address-line1">

However, this might be confusing to mobile developers who are not accustomed to html input related properties. Is there any use case for this in mobile devices?

@goderbauer goderbauer added the P2 Important issues not at the top of the work list label Aug 9, 2022
@flutter-triage-bot flutter-triage-bot bot added team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

No branches or pull requests

5 participants