diff --git a/js/src/collapse.js b/js/src/collapse.js index 13c44502ca6b..cb550e42f99b 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -363,7 +363,9 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - event.preventDefault() + if (!$(event.target).is('input')) { + event.preventDefault() + } const target = Collapse._getTargetFromElement(this) const data = $(target).data(DATA_KEY) diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index a7bcaad9cd97..01bc5adb96a7 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -513,4 +513,20 @@ $(function () { }) $target.trigger($.Event('click')) }) + + QUnit.test('should not prevent event for input', function (assert) { + assert.expect(2) + var done = assert.async() + var $target = $('').appendTo('#qunit-fixture') + + $('
') + .appendTo('#qunit-fixture') + .on('shown.bs.collapse', function () { + assert.ok($target.attr('aria-expanded') === 'true') + assert.ok($target.prop('checked')) + done() + }) + + $target.trigger($.Event('click')) + }) })