aboutsummaryrefslogtreecommitdiff
path: root/js/button.js
diff options
context:
space:
mode:
authorPatrick H. Lauke <[email protected]>2015-04-17 18:19:11 +0200
committerPatrick H. Lauke <[email protected]>2015-04-17 18:19:11 +0200
commit8549722846038f2e6e9075bd41831fd0184706c4 (patch)
treea0e3b2769664c745891b45887e0dddf0810cc843 /js/button.js
parent3a279860b018e8cfe1aa3f4e941c826dc05307c3 (diff)
parent66d71136e668cf7bc8a311299fad9b773b76285a (diff)
downloadbootstrap-8549722846038f2e6e9075bd41831fd0184706c4.tar.xz
bootstrap-8549722846038f2e6e9075bd41831fd0184706c4.zip
Merge pull request #16226 from patrickhlauke/radio-toggle-kbd-fix
Fix radio button toggle behavior for keyboard users
Diffstat (limited to 'js/button.js')
-rw-r--r--js/button.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/js/button.js b/js/button.js
index 7c7c021f9..3b86f35d4 100644
--- a/js/button.js
+++ b/js/button.js
@@ -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 {
@@ -107,7 +107,7 @@
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))