-
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
Resetting forms on document reactivation #9019
Comments
Related chromium bug: https://crbug.com/1418756 I understand the issues you raise about page authors getting caught off guard, or having a hard time dealing with this behavior. However, from the user's perspective, it feels odd to have the behavior change depending on whether the page is bf-cached or not. I.e. sometimes you hit "back" and your fields are clear, and sometimes they still contain the old input. Does the |
I think you're right, it will be surprising. So there may not be anything good action to take here. Perhaps just warning authors "hey you have an onchange but no onreset for this autocomplete=off field" so that they are aware of the gotcha is the best we can do. |
It would be very confusing for the page to get reset when coming out of bfcache. Has webkit gotten bug reports about its behavior? |
I'm not aware of any, but we'd be okay with removing this functionality. |
cc @whatwg/forms |
@smaug---- wrote
Confusing for who? A user has pressed back, they don't know about BFCache, not resetting |
One thing we discussed in the call is that this should be consistent between a session history entry having a pointer to a document and it not having a pointer to a document. In particular in the latter case user agents perform form restoration and it should not be the case that we only reset there. Another point that was brought up is that we should revisit whether I've also done some quick archeology:
|
I'm ok considering whether |
What is the use case? |
An input element that is always cleared when the user returns to the page. At least one site doing this is www.google.com. |
The spec says for autocomplete=off:
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-off The main intent is to avoid prefilling by the UA, not preventing restore on history navigation. Assessing whether not restoring on navigation makes sense for the stated use cases:
google.com falls into the third category, but wants to clear the value on history navigation. However, for pages in general, I think it doesn't makes sense to clear the value on history navigation just because the page implemented custom autocomplete. I ran a query in httparchive to find examples of how https://docs.google.com/spreadsheets/d/1zE62w1lFEi-hD2e5wQEuYDi69JNukn8LYu4pUr_6lZE/edit?usp=sharing Of these, there are 257 pages with an https://docs.google.com/spreadsheets/d/1GSKnciAyWObxFUSrtLvrTicGZCJbWyd1tw5xNQX2-VE/edit?usp=sharing I haven't yet looked at these in detail. |
Even google.com doesn't clear the value on history navigation when navigating between google.com/search pages, only when going back to the home page. (To reproduce, search for something in google.com, then on the results page, edit the search to something else, press enter, then go back in history.) In both cases This suggests that either restoring is OK and sites can clear manually in the
All 3 browsers do not implement the spec for |
Thanks for the detailed analysis! It feels like we shouldn't require JS to implement this behavior, since an attribute feels the most natural. It's quite frustrating to developers to need to do tricks to get browsers to do what they want, such as Quick side note about |
A new attribute to control restoration SGTM, with the default being to restore (regardless of |
As a FACE (form-associated custom element) library author, I would assume The first of the controls is a custom autocomplete with In my opinion, it would be reasonable for a user to assume because controls in their viewport were restored, all the fields were restored. It's not reasonable to think the user needs to verify the entire page because some elements follow special rules hidden to the user. As the author, should I code special handling? Should I need to do some special detection that a form getting restored may have a field with |
The HTML Spec says for reactivation that fields with
autocomplete=off
should be reset.This is the only instance in the spec of a reset being triggered like this. All other sources of resets are from calls to
reset()
in JS or from reset buttons. Authors of pages that have no reset button might be surprised that resets can still occur. and only listen for change events Such a page could have its JS state get out of sync with the form state, making this a potential source of hard to repro bugs.It also seems that Chrome and Mozilla do not implement the spec but Safari does.
I don't have a great suggestion for what to do instead, just
You can test the behaviour of browsers with https://textarea-autocomplete-bug.glitch.me/
@mfreed7 @domenic @rakina
The text was updated successfully, but these errors were encountered: