bootstrap-multiselect icon indicating copy to clipboard operation
bootstrap-multiselect copied to clipboard

Click inside check-box triggers postback in v0.9.16

Open RomanCar opened this issue 4 years ago • 6 comments

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.

RomanCar avatar Nov 16 '20 17:11 RomanCar

I could not reproduce this behavior in Chrome v86, Firefox v83 and IE 11. Which browser and version are you using?

s-eckard avatar Nov 18 '20 08:11 s-eckard

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.

xabaras avatar May 06 '21 08:05 xabaras

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

andyspix avatar Jul 07 '21 17:07 andyspix

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>'

andyspix avatar Jul 07 '21 21:07 andyspix

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.

tiesont avatar Jul 08 '21 04:07 tiesont

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.

andyspix avatar Jul 08 '21 17:07 andyspix