Open
Description
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.
Activity