0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Collapse - do not prevent event for input and textarea

This commit is contained in:
Johann 2017-03-27 10:08:39 +02:00 committed by GitHub
parent 8edfe0ff56
commit 24924c23b2
2 changed files with 19 additions and 1 deletions

View File

@ -363,7 +363,9 @@ const Collapse = (($) => {
*/
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
event.preventDefault()
if (/input|textarea/i.test(event.target.tagName)) {
event.preventDefault()
}
const target = Collapse._getTargetFromElement(this)
const data = $(target).data(DATA_KEY)

View File

@ -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'))
})
})