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

form widgets: support autofill, and restore value on form reset or back button #655

Open
wkeese opened this issue Sep 26, 2016 · 0 comments

Comments

@wkeese
Copy link
Member

wkeese commented Sep 26, 2016

Three cases when form widget values should be filled automatically:

  • autofill: user visits a page they've visited before, or a similar page, and the browser automatically fills in things like name and address
  • back button: user clicks a link on a page to go to a new page, then presses the back button to return to the original page
  • form reset: form widget values should be restored to their original setting

A poor man's solution to make form reset work is to do like Toggle.js does:

attachedCallback: function () {
    this._initState = this.checked;
},

afterFormResetCallback: function () {
    this.checked = this._initState;
},

But that doesn't support the back button or autofill.

The original idea to make form reset, autofill, and the back button work was that apps would declare form widgets like this:

<d-combobox>
   <input name="foo">
</d-combobox>

If specified, the <input> in the markup would take the place of the <input attach-point="valueNode"> in the template.

Then, whenever the user reloaded the page or reset the form, the browser would reset the <input name="foo"> to its previous value, and form widgets like Combobox would react to that new value.

However, that was never implemented. And also, it doesn't work for programmatically created form widgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant