diff options
| author | Patrick H. Lauke <[email protected]> | 2015-04-03 22:32:49 +0100 |
|---|---|---|
| committer | Patrick H. Lauke <[email protected]> | 2015-04-11 19:21:55 +0200 |
| commit | 1b9baa0d98019eba187e65102959fff60d06538a (patch) | |
| tree | c9bdc5cfdbe878b9f4632dc060d7097413f16504 | |
| parent | bb6af65ca6acc831092fa1fcb1c795dbe081ab4c (diff) | |
| download | bootstrap-1b9baa0d98019eba187e65102959fff60d06538a.tar.xz bootstrap-1b9baa0d98019eba187e65102959fff60d06538a.zip | |
Don't preventDefault radio buttons
as this breaks keyboard navigation for radio button toggles (see
https://github.com/twbs/bootstrap/issues/16223)
| -rw-r--r-- | js/button.js | 6 |
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)) |
