]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Don't preventDefault radio buttons
authorPatrick H. Lauke <redux@splintered.co.uk>
Fri, 3 Apr 2015 21:32:49 +0000 (22:32 +0100)
committerPatrick H. Lauke <redux@splintered.co.uk>
Sat, 11 Apr 2015 17:21:55 +0000 (19:21 +0200)
as this breaks keyboard navigation for radio button toggles (see
https://github.com/twbs/bootstrap/issues/16223)

js/button.js

index 7c7c021f95853d5cdd7d3e8ca16c8216cb0cd500..3b86f35d46ba45f519911354df9e352915e76239 100644 (file)
@@ -56,8 +56,8 @@
     if ($parent.length) {
       var $input = this.$element.find('input')
       if ($input.prop('type') == 'radio') {
-        if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
-        else $parent.find('.active').removeClass('active')
+        if ($input.prop('checked')) changed = false
+        if (!$input.prop('checked') || !this.$element.hasClass('active')) $parent.find('.active').removeClass('active')
       }
       if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
     } else {
       var $btn = $(e.target)
       if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
       Plugin.call($btn, 'toggle')
-      e.preventDefault()
+      if (!$(e.target).is('input[type="radio"]')) e.preventDefault()
     })
     .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
       $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type))