[Dropdown] The selected item should change when reset the form #650
-
Bug ReportCurrently, the dropdown inside the form has no affection when the form triggers the reset event. It keeps showing the current selected value instead of the initial value. The select element is already responding properly to the reset event. But, the dropdown text container The other components: radio, checkbox are responding the reset event properly. Steps to reproduce
Expected resultThe dropdown should also reset the text with it's initial value. Actual resultThe dropdown keeps showing the current selected value. TestcaseOpen this fiddle (https://jsfiddle.net/v25tau6j/). Make some changes in the form and then click reset button. Version2.7.4 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
According to the docs, resetting a form should be done differently in FUI. The usual See https://fomantic-ui.com/behaviors/form.html#reset--clear-fields |
Beta Was this translation helpful? Give feedback.
-
Another Workaround if you still want to stick with the $('.ui.form').form({
selector: {
reset: '[type="reset"]'
}
}); |
Beta Was this translation helpful? Give feedback.
-
@lubber-de Thanks, it works for resetting the dropdown. However, it brings another issue to me. I've a form with Native form event: https://jsfiddle.net/bkLhzmv8/ Please watch the console for the output returns from the form change event. In my project, I have change event attaches to the form and send Ajax request to server when the change happens immediately. Resetting with FUI With native form reset event, I don't have that problem. But, just the dropdown text not get updated. |
Beta Was this translation helpful? Give feedback.
-
Here is a proposal: https://jsfiddle.net/se37b2qh/ There is too much stuff to consider and change and probably breaks other code if we would change the |
Beta Was this translation helpful? Give feedback.
-
@lubber-de Thank you. I'll look the fiddle and check whether your proposal suits in my work. If not, I'll leave it as it's or use the native selection element. I'm closing this issue then. |
Beta Was this translation helpful? Give feedback.
Here is a proposal: https://jsfiddle.net/se37b2qh/
The onchange is still triggered, but you check for the onchange event on the dropdown directly if the value was empty -> then it was a reset and your code is not doing any ajax-calls
There is too much stuff to consider and change and probably breaks other code if we would change the
set.value
method to not trigger the onchange event in some cases (and there can be a lot), so for the time being, i suggest you catch this in your own code if its not possible for you to use the "offical" FUI way