Skip to content

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

Open
@wkeese

Description

@wkeese

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions