Skip to content

Commit

Permalink
Collapse - Fix check to not prevent event for input and textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S authored Mar 28, 2017
1 parent 48c5efa commit fb42d6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/src/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ const Collapse = (($) => {
*/

$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
if (/input|textarea/i.test(event.target.tagName)) {
if (!/input|textarea/i.test(event.target.tagName)) {
event.preventDefault()
}

Expand Down
3 changes: 2 additions & 1 deletion js/tests/unit/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,14 @@ $(function () {
})

QUnit.test('should not prevent event for input', function (assert) {
assert.expect(2)
assert.expect(3)
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($(this).hasClass('show'))
assert.ok($target.attr('aria-expanded') === 'true')
assert.ok($target.prop('checked'))
done()
Expand Down

0 comments on commit fb42d6e

Please sign in to comment.