-
Notifications
You must be signed in to change notification settings - Fork 36
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
support form reset #584
Comments
With updated checkouts, I've tried the "reset" button in tests/functional/Select.html and it works for me as (I) expected. Tested with Chrome and FF / Win7. That is, after loading the test, I change the value of a single select, for instance I pick "Option 2". After "reset", it shows again "Option 1". Also, checking in the debugger the value prop. of the widget, it is consistent with what is shown in the DOM. It doesn't "clear" the value, it puts back the initial value. (The reset/submit buttons hold for the
Indeed, reset is broken. It was working some (long) time ago. In the debugger I see the |
The default FormWidget and FormValueWidget afterFormResetCallback() methods reset the widget according to the value (or checked property) of this.valueNode. Strangely, there's no code in FormWidget and FormValueWidget to do that on initialization. That should be added in the future. Also, the original code in deliteful got the form reference from this.valueNode.form, but that assumes that the widget is rendered before attachedCallback(), which won't always be true (see #404). So instead, I'm just tracing up the DOM tree for the nearest <form> ancestor. Fixes #423, refs ibm-js/deliteful#584.
Refs ibm-js/delite#423, #584. The form reset code for ComboBox, Select, Slider, and Toggle was apparently added but never tested. It's unclear if it worked before or after this change. The original commits for the form reset handling were: * Combobox: 59e59c0 * Select: e80ca84 * Slider: c8cf2f0 * Toggle: 6ccd370
Combobox, Checkbox, and Radiobutton unconditionally create the Select is a similar story except the template has a |
Also create embedded <input> (aka this.valueNode) if it does not exist. The widget subclass should add this.valueNode to the DOM if it's not already there. It shoudn't call appendChild() unnecessarily though as that will break back-button support on IE. See deliteful/tests/functional/StarRating-formback.html for test. Also (if desired) the widget should set display:none on the <input>, either directly or via a stylesheet. Currently does not handle some complex cases, such as: * deliteful/Select should support an embedded <select> rather than <input> * deliteful/Checkbox and Radiobutton's embedded <input> also has "checked" property; should also sync that property. Fixes #394, refs #423 tangentially, refs ibm-js/deliteful#584 too.
…from embedded <input>. Refs ibm-js/delite#394, refs #584 too.
ComboBox, Select, Slider, and Toggle have code that supposedly supports form reset. I.E. when the user presses a
<form>
's reset button, those widgets inside the<form>
revert to their original values.However, AFAICT there are no automated tests for these features, and not even manual tests.
Furthermore, the API to specify the original value is unclear. For example, given markup like:
Then it's unclear whether the slider's original value should be 5 or 10, and correspondingly whether the reset button should set the slider to 5 or 10. The code seems inconsistent, for example the slider's original value may be 5, but the reset button may set the value to 10.
Form auto-fill and back-button support are related. In both cases, on page load the browser sets a value for the
<input>
which the widget should obey. I'm not sure what form reset is supposed to do in that case, but the widgets should do whatever native controls do.The original commits for the form reset handling were:
We should add automated tests, fix the code if it doesn't work, and document the right way to specify form widget's initial values.
The text was updated successfully, but these errors were encountered: