JS - button plugin stop event propagation on checkboxes/radio when browsing with keyboard
See original GitHub issueAfter looking at the previous issue https://github.com/twbs/bootstrap/issues/26904
And play with the associated codepen : https://codepen.io/Johann-S/pen/GBqoZG?editors=1111
I could still reproduce the use-case in current documentation on 3 way radio toggle buttons : https://getbootstrap.com/docs/4.3/components/buttons/#checkbox-and-radio-buttons
1 - browse the input element with keyboard 2 - change the selected item using keyboard arrow 3 - look in the console document.getElementById(‘option2’).checked or other optionid the current value isn’t the visual one
Works well when using mouse
My first tests :
- $(input).trigger(‘change’) is well executed with keyboard or mouse but maybe there’s sub-jascent events to propagate?
- by removing the
event.preventDefault()
from plugin initialisation state change well with keyboard
$(document)
.on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => {
// event.preventDefault()
First tests doesn’t show anything is broken by removing this
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
bootstrap checkbox button event propagation issue
I've been trying to stop propagation on the checkbox thinking that where ever bootstrap is attaching the event I might be able to...
Read more >How to use stopPropagation function in KeyboardEvent
When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. Most used builtins functions....
Read more >Angular directives for Bootstrap - AngularUI
This repository contains a set of native AngularJS directives based on Bootstrap's markup and CSS. As a result no dependency on jQuery or...
Read more >Accessible Rich Internet Applications (WAI-ARIA) 1.2 - W3C
This is often a more convenient way of providing keyboard navigation within widgets, such as a listbox , where the widget occupies only...
Read more >change the selection of radio button on enter press - You.com
Using HTML rather than jQuery, browsers have a built-in mechanism to select form options for keyboard input + a modifier key using the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i suspect the preventdefault is a remnant of the old way in which these buttons were coded (seem to remember that it wasn’t the actual
<input>
that ever received focus, but the parent element, and we then had to fake-click the hidden<input>
etc). i’ll have a look tonight, as i’d really like to put this to bed once and for all 😉Think this issue can now be closed following #28834 (should have autoclosed but didn’t…)