Skip to content

Commit

Permalink
Collapse - do not prevent event for input
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Mar 25, 2017
1 parent d2b9191 commit 36718ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions js/tests/unit/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<input type="checkbox" data-toggle="collapse" data-target="#collapsediv1" />').appendTo('#qunit-fixture')

$('<div id="collapsediv1"/>')
.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'))
})
})

0 comments on commit 36718ad

Please sign in to comment.