Closed Bug 1413118 Opened 2 years ago Closed 2 years ago

[Form Autofill] Fill "tel-national" to a recognized "tel" field even the international format passes "maxlength"

Categories

(Toolkit :: Form Manager, defect, P5)

defect

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox57 --- wontfix
firefox58 --- fixed

People

(Reporter: lchang, Assigned: lchang)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [form autofill:MVP])

Attachments

(1 file)

It's a follow-up bug of bug 1405997.

Most websites expect the national format of a telephone number. However, they might set the "maxlength" of the field more than a valid national format (10 characters in US) because they expect the formatted number or they will help to format it after a user enters the number.

In order to better support the targeting websites, we should fill "tel-national" to a recognized "tel" field even the international format passes "maxlength" check.
Assignee: nobody → lchang
Status: NEW → ASSIGNED
See Also: → 1414102
Comment on attachment 8924423 [details]
Bug 1413118 - [Form Autofill] Fill "tel-national" to a recognized "tel" field even the international format passes "maxlength".

https://reviewboard.mozilla.org/r/195720/#review201816

LGTM! Thanks.

::: browser/extensions/formautofill/FormAutofillHandler.jsm:341
(Diff revision 1)
>      };
>      if (element.pattern) {
>        if (testPattern(profile.tel)) {
>          return;
>        }
> -    } else if (element.maxLength) {
> +    } else if (element.maxLength && detail._reason == "autocomplete") {

checking `element.pattern` or `element.maxLength` is to make sure their existence should be considered as the first priority. If we want to follow the concept, I think the check would be better to look like this:
```JS
} else if (element.maxLength) {
  if (detail._reason == "autocomplete" && profile.tel.length <= element.maxLength) {
    return;
  }
}
```

or we can just use a simpler version:
```JS
} else if (element.maxLength && detail._reason == "autocomplete" && profile.tel.length <= element.maxLength) {
  return;
}
```
Attachment #8924423 - Flags: review?(selee) → review+
Makes sense. Thanks.
Pushed by lchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c760f9b3e6c9
[Form Autofill] Fill "tel-national" to a recognized "tel" field even the international format passes "maxlength". r=seanlee
https://hg.mozilla.org/mozilla-central/rev/c760f9b3e6c9
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
The combination of "P5" and "form autofill:MVP" has me confused.  In any case, this is too late for 57, so wontfix.
You need to log in before you can comment on or make changes to this bug.