bootstrap-multiselect
bootstrap-multiselect copied to clipboard
Click inside check-box triggers postback in v0.9.16
In new version v0.9.16 if you click directly in check-box (input.form-check-input), postback is triggered. Click on label (label .form-check-label) works as before.
I could not reproduce this behavior in Chrome v86, Firefox v83 and IE 11. Which browser and version are you using?
I've got the same issue in Firefox v88 not in Chrome. When i click on an option it is all ok, when I click on a checkbox the form gets submitted.
Seeing the same issue, appears to be Firefox-Mac specific: Safari 14 - works as expected Chrome 91 - works as expected Firefox 89 - posts after click in any checkbox Firefox 83 - posts after click in any checkbox
I'm not 100% clear on all of the mechanisms involved, but it appears that a submit event is generated from the button elements used to construct the dropdown after it is becomes :active. (https://stackoverflow.com/questions/55929696/why-does-document-activeelement-produce-a-different-result-on-mac-using-firefox may be relevant to debug)
I believe that forcing all button elements to be type='button' in the templates prevents any undesired submit events from firing. IE: lines 446-449 become:
option: '<button type="button" class="multiselect-option dropdown-item"></button>',
divider: '<div class="dropdown-divider"></div>',
optionGroup: '<button type="button" class="multiselect-group dropdown-item"></button>',
resetButton: '<div class="multiselect-reset text-center p-2"><button type="button" class="btn btn-sm btn-block btn-outline-secondary"></button></div>'
If the button(s) don't have a type="whatever"
specified, the type is assumed to be "submit". So, yeah, that would trigger a form submit.
It is interesting that neither Chrome or Safari show the same behavior with the checkbox buttons (all three browsers show type='submit' when inspected). I suspect Mac support (or lack thereof) of :focus on buttons is implemented differently across the browsers, resulting in this artifact in Firefox.