From 24924c23b24c1b196c42166ebe9a17d31f0ee720 Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 27 Mar 2017 10:08:39 +0200 Subject: [PATCH] Collapse - do not prevent event for input and textarea --- js/src/collapse.js | 4 +++- js/tests/unit/collapse.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/src/collapse.js b/js/src/collapse.js index 13c44502ca..6f09fcadd8 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 (/input|textarea/i.test(event.target.tagName)) { + 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 a7bcaad9cd..01bc5adb96 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')) + }) })