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

Add the autocorrect attribute to the HTML spec. #5841

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

whsieh
Copy link

@whsieh whsieh commented Aug 18, 2020

Issue: #3595


/acknowledgements.html ( diff )
/dom.html ( diff )
/form-elements.html ( diff )
/forms.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/input.html ( diff )
/interaction.html ( diff )

@othermaciej
Copy link

@whsieh to pass the participation check, you need to make your membership in https://github.com/apple-whatwg publicly visible.

@whsieh
Copy link
Author

whsieh commented Aug 18, 2020

@whsieh to pass the participation check, you need to make your membership in https://github.com/apple-whatwg publicly visible.

Done, thanks!

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

I think it would be good if @kojiishi and @dtapuska took a look as well to see if it matches their expectations.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@mtrootyy
Copy link

mtrootyy commented Aug 19, 2020

  1. The following sentence should be added.

User agents can support autocorrection of editable text, either in form controls (such as the value of textarea elements), or in elements in an editing host (e.g. using contenteditable).

Because it is difficult that all user agents support autocorrection of all natural language.
There are similar sentence in the section of "Spelling and grammar checking". (https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking)

  1. The following sentence should be added.

The autocorrect attribute never causes autocorrection to be enabled for input elements whose type attribute is in one of the URL, E-mail, or Password states.

Because autocorrection interfere with input or editing on input elements whose type attribute is in one of the URL, E-mail, or Password states.
Correct spelling as a natural language is not required on input elements whose type attribute is in one of the URL, E-mail, or Password states.
There are similar sentence in the section of "Autocapitalization". (https://html.spec.whatwg.org/multipage/interaction.html#autocapitalization:attr-autocapitalize-4)

@whsieh
Copy link
Author

whsieh commented Aug 19, 2020

Thank you for the comments, @annevk and @mtrootyy!

I've updated the pull request accordingly, and will add a new subtest to the accompanying web-platform-tests PR that will cover autocorrection in password, email and URL fields.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good; thanks so much for working on this!

Most comments are editorial, but there's one potentially substantial issue in the processing model, related to presence/absence of the attribute vs. its on/off state.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@domenic

This comment was marked as resolved.

@whsieh

This comment was marked as resolved.

@xfq xfq added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Oct 27, 2020
Base automatically changed from master to main January 15, 2021 07:58
@domenic

This comment was marked as resolved.

@fschroiff

This comment was marked as resolved.

@tomlube

This comment was marked as resolved.

@annevk annevk added addition/proposal New features or enhancements topic: editing labels Oct 11, 2022
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to take care of the remaining comments. I left two questions, one for @whsieh and one for @domenic. I haven't looked at whether the tests deal with the autocapitalize-and-autocorrect-inheriting elements.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated
Comment on lines 78698 to 78700
<li><p>If the <code data-x="attr-autocorrect">autocorrect</code> content attribute is present on
<var>element</var>, and its value is not the empty string, then return the <span>autocorrection
state</span> of the attribute.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whsieh one more question. Why does this specifically check for the empty string? Is that not handled by the missing value default? Is the intent here that <input autocorrect form=x><form id=x autocorrect=no></form> results in no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whsieh one more question. Why does this specifically check for the empty string? Is that not handled by the missing value default? Is the intent here that <input autocorrect form=x><form id=x autocorrect=no></form> results in no?

...that's a good question. I think I was just trying to be consistent with the behavior of the autocapitalize attribute (and state), though for autocorrect it probably makes more sense to default to "on".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I guess I don't care too strongly.

Another oddity I noticed is that autocapitalize doesn't return the used concept, but autocorrect does. That seems more useful so I suggest we keep that. Perhaps it's worth a note over in autocapitalize or someone more ambitious than me could try to clean it up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure that the case @annevk mentioned is tested? The tests do look pretty comprehensive, so maybe it is already :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are tested as far as I can tell and match the current text.

@r12a
Copy link

r12a commented Oct 11, 2022

Should autocorrection be language-dependent? How does the browser know which dictionary to use to look up words, and does it alter its triggers for lookup for a script that doesn't use spaces, such as Chinese or Japanese or Thai (the latter has spaces but for phrase separation, rather than word), or for scripts that use different punctuation marks than English? Is it able to tell which language a user is using when they fill in form fields if that user fills in forms in more than one language?

@annevk
Copy link
Member

annevk commented Oct 11, 2022

Much like with autocapitalization, this does not attempt to define how autocorrection works. It merely acknowledges that it's a feature of input methods such as virtual keyboards that at times is useful to disable.

@annevk annevk requested a review from domenic October 11, 2022 16:43
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this back up! What's the reason for not using the same behavior of inheriting from the editing host as autocapitalize does?


<dl>
<dt><dfn data-x="concept-autocorrection-on">on</dfn>
<dd>The user agent is permitted to automatically correct spelling errors while the user types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use "may" and "must not"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used should not as this is about UI.

source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated
Comment on lines 78698 to 78700
<li><p>If the <code data-x="attr-autocorrect">autocorrect</code> content attribute is present on
<var>element</var>, and its value is not the empty string, then return the <span>autocorrection
state</span> of the attribute.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be sure that the case @annevk mentioned is tested? The tests do look pretty comprehensive, so maybe it is already :)

source Show resolved Hide resolved
source Show resolved Hide resolved
@annevk
Copy link
Member

annevk commented Oct 12, 2022

What's the reason for not using the same behavior of inheriting from the editing host as autocapitalize does?

I'm not sure, but note that autocapitalize doesn't reflect this in its getter. It's non-script-observable behavior. So in that sense we could always change this later if it turns out to be a problem. (The autocapitalize getter is worse in that it does not acknowledge URL, Email, and Password controls either. That might be something we want to try to fix, but that getter is even older so it might be high risk for little reward.)

@whsieh thoughts?

@smaug----
Copy link

How would a webpage know whether autocorrection is supported by the UA or not? Site might provide its own correction as a fallback.
I could imagine that on less common OSes and especially when using less common languages autocorrection isn't always available.
I guess there are similar issues with spellchecking too though.

@annevk
Copy link
Member

annevk commented Oct 13, 2022

Yeah that would apply to spellchecking and autocapitalization as well. I could see two options:

  1. Don't expose these features. (As long as you can fingerprint the OS this should not add to the fingerprinting surface.)
  2. Add some kind of supports() thing. (Per rationale above should also not add to the fingerprinting surface.)

I'm not sure we should do either until it becomes a concrete problem for someone though as there's also a question to what extent web developers would care about less common OSes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. topic: editing
Development

Successfully merging this pull request may close these issues.

None yet

10 participants