-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
New attribute to control UA-provided writing assistance #9065
Comments
cc @whatwg/forms |
Microsoft is interested in implementing this in Edge and Chromium :) |
Autocomplete works differently on different form controls, see https://html.spec.whatwg.org/#inappropriate-for-the-control Editing hosts don't have a way to signal what kind of input is accepted (e.g. single line vs multiline). Which "groups" should editing hosts be part of? All of them? |
WebKit is also interested in this. (For maximum clarity, Chromium and Edge count as a single implementer for WHATWG purposes.) |
I think |
Here is our proposal to adjust the wording of 4.10.18.7.1 Autofill to allow for editing host elements to be eligible for autofill and the autocomplete attribute. |
Seems reasonable, but I'm not an autocomplete expert. I do worry about the leakage of sensitive information, if autocomplete can more easily be tricked into filling general |
What are the considerations around events? |
@bmathwig What kind of input type are you thinking of using for the corresponding beforeinoput and input events? And how does this fit with Microsoft's plans with replacing a lot of contenteditable usage with EditContext which Microsoft is also working on? In the examples mentioned in your proposal, where would the suggestions of autocompletion for the code editor come from? Is this one of the existing autocomplete types like address, etc.? Would it work in the middle of an element with other content preceding and following it or will it replace the entire content of the contenteditable element? |
@bmathwig Also, will the auto-complete text that is stored in the browser contain richtext itself? So if the user fills in their address in one place and uses |
tl:dr; I have a couple of concerns about this proposal which basically boil down to the point that the proposal endorses the use of Here are the details. We observe that
Chrome compensates for these problems as well as possible by running heuristics in the browser and crowdsourcing. My concern is that if
In summary, I believe that are be better off if fields that are semantically parts of a form remain form controls. If All that said, @johanneswilm raises a lot of good questions that are also unclear to me and would pertain to such a |
Thanks @battre! The intent of this proposal is not to make contenteditable elements targets for form fill (although it technically already can be today - see below). Rather, it is to extend the scope of the autocomplete attribute beyond just form autofill scenarios. For editable regions, the use cases for autocomplete are mainly for writing assistance to allow the user to write faster, not necessarily for filling forms. There are a couple of subtleties in terms of interactions with form elements:
An alternative solution could be to create a new attribute to support "autocomplete for writing assistance" scenarios. However, since these are also autocompletion scenarios, it would be ideal to just reuse the existing autocomplete attribute. |
Autocompletion on input elements fires these events today. I would expect them to fire similarly for contenteditables.
For existing autocomplete scenarios, the spec doesn't prescribe where the autocompletion comes from. Neither does it specify whether the autofilled content should replace existing content or just be inserted. This is left up to the UA. For writing assistance scenarios, it also seems reasonable to leave this up to the UA.
Yes, preserving rich text does seem quite tricky to get right and unclear how useful it would be. Do you have scenarios in mind where this might be desirable? Storing and inserting the autocomplete text as plain text seems sufficient. |
In that case, I would think it's a bad idea to try to add this to contenteditable. Contenteditable elements are generally controlled by thousands of lines of JavaScript that try to ensure that similar markupis produced all platforms and browsers. Firefox was the last browser to remove some major elements that worked differently from the other browsers (table controls). Introducing new issues that work differently doesn't seem like a good idea. That's different for Given that JS editors are such large programs also means they have plugins that provide auto-completion [1] that work highly specific for a given type of content. It seems like it would be difficult to create a one-size-fits-all model that is UA specific to replace all of these. [1] For example https://ckeditor.com/cke4/addon/autocomplete or https://github.com/curvenote/editor/tree/main/packages/prosemirror-autocomplete |
What categories of events are you referring to? It seems like eventing for autocomplete should work similar to the user just replacing/inserting that content via manual input. Events for input, composition, etc. are already fired on text control elements like this, I would expect those events to also work the same way for contenteditables. |
I would expect autocomplete to only support plain text content, perhaps that can be made explicit in the spec. Thus, this would work similar to the user manually replacing/inserting that same content via text input methods (ex. typing, composition), which wouldn't be site breaking. |
Looking at the kind of autocomplete existing richtext editors based on contenteditable do, they would for example put tags around a specific term that was inserted through auto-completion to give it a different color or style. The code editor mentioned in your explainer [1] would likely need to do that if it is supposed to work like other web-based code editors.
Ok that would remove one potential issue. But if I understand you correctly, it would be up to the UA whether to replace the entire contents or just add something new, right? So the code editor in your example could work in Safari on Mac in a way where it would just suggest an entire code snippet to the user and then replace everything else in there, whereas on in Edge on Windows it may give suggestions for specific terms to be used within the code editor? If that is the case, who would opt for using this feature that is only working sometypes as required for some users rather than use one of the existing JavaScript code editors with an existing auto-complete plugin that work all the time and everywhere? I'm thinking maybe the usecase for this is something else, such as an address input on a simple form field where the user wants to use a contenteditable element instead of a textarea for some reason - maybe because there are situations where there could be richtext in the address? That then carries with it the issues mentioned by @battre above. |
The scenarios for autocomplete on contenteditable are primarily about writing assistance, not form fill. I've updated the use cases section in the explainer, hopefully that helps. For the use cases I can imagine, they all seem to be about inserting content where the user is typing (replacing the user's selected text if necessary). My reasoning for leaving the decision about how to insert content into the DOM up to the UA is that autocomplete is about browser-powered functionality and it is unclear what browsers might come up with in the future. The intent is that regardless of what types of writing assistance UAs add, authors should be able to control it with the |
Ok, that makes more sense. So it looks like you are planning for a scenario where a UA or an operating system is providing something like text completion using a large language model (LLM) either by directly completing the text or by figuring out that this would be an appropriate place to insert the users phone number, credit card number or similar and then offering that as something to easily fill in. I can see how it would make sense to signal to either the UA or browser extensions (like Grammarly and new similarly IA-based offerings) that this is a field where such assistance would be desired or it should not be offered. This kind of assistance is qualitatively different from spell-checking, so therefore you need to have two distinct keywords. I wonder then, given that this usage is quite different from the form-filling help that the I also think it should be made clear which input type (before input event and input event) will be used for this. There is called called Under these circumstances, would it not also make sense to add this to EditContext in parallel? I have seen your notes on that, but the use cases you like, like a Facebook editor, already use a sophisticated and highly complex contenteditable based-editor that will also possibly be replaced by EditContext once shipped. |
From the explainer:
Most production level JS richtext editors on the web are quite sophisticated and will consist of thousands of lines of code and have 5-20 years of development behind them. However, a lot of these can be run completely in JavaScript (open source libraries such as CKEditor, ProseMirror, TinyMCE, etc.). And most of the more robust ones already do what EditContext promises in that they diff the dom after browser-initiated DOM changes and then potentially roll back some of those. Switching to EditContext will in many such cases mean a simplification of the code as one can skip diffing and rolling DOM changes back. So if and when EditContext actually ships eevrywhere, I would think that a lot of these libraries will eventually switch to it. However, hosting a LLM on a server is a bit more complicated than serving a JS-based editor on a website. I would therefore think it makes a lot of sense to add both spell checking and this new feature also to EditContext. That would also be consistent with other decisions you made, such as adding using the native selection as an option to EditContext even though Google Docs and other larger online word processors don't make use of it, precisely because it is also to be useful for smaller sites. |
Per resolution in #9966, Microsoft can draft up a spec PR for the new attribute. Unless there are strong objections, I plan to start with |
…d of extending autocomplete. (#726) Per discussion in whatwg/html#9065, a new attribute is being proposed to control UA-provided writing assistance. This change updates the explainer to reflect the updated proposal.
Thanks @mfreed7, @marcoscaceres, @domenic for the feedback on #10018. Calling out a few points about the new attribute that came out of that, which might be worth discussing in more detail during the next WHATNOT meeting.
|
Per discussion on the above points during today's WHATNOT call, the only suggested change to #10018 was to align the inheritance behavior with |
This should define interaction with |
@sanketj Why does it work for type=email but not type=telephone? |
I guess the principle of the current list is "types that expect character input that's not numbers-only, excepting password". |
The scope of this new attribute just grants authors the ability to turn off UAs' writing suggestions capabilities. An attempt hasn't been made to standardize the details of those capabilities, and they could vary widely. So while I agree that the interaction of Maybe worth a new issue? |
@dandclark it seems weird to me to include email but not telephone. If this feature can suggest email addresses, surely it can suggest telephone numbers as well. |
@annevk I think that list is a reasonable starting point, and given the current design in #10018 it could be expanded without breaking backwards compatibility, but I don't have any particular objection to adding "telephone". |
The current specification allows for the autocomplete attribute to exist on elements of type
<input>
,<textarea>
, and<select>
. With the rise in popularity of rich text controls usingcontenteditable
, we should consider allowing elements who havecontenteditable=true
to utilize theautocomplete
attribute. While not a common scenario within the scope of form fields, there are applications for text hinting and autofill withincontenteditable
elements.One existing example of a form field being replaced by
contenteditable
exists in the example section of its specification.The text was updated successfully, but these errors were encountered: