question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JS - button plugin stop event propagation on checkboxes/radio when browsing with keyboard

See original GitHub issue

After 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

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
patrickhlaukecommented, Mar 27, 2019

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 😉

0reactions
patrickhlaukecommented, Aug 30, 2019

Think this issue can now be closed following #28834 (should have autoclosed but didn’t…)

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found