diff --git a/js/src/collapse.js b/js/src/collapse.js index 1e2d4a63ee..782d82a2fc 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -121,7 +121,7 @@ const Collapse = (($) => { let activesData if (this._parent) { - actives = $.makeArray($(Selector.ACTIVES)) + actives = $.makeArray($(this._parent).find(Selector.ACTIVES)) if (!actives.length) { actives = null } diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 892da52ed2..dba15e8659 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -52,6 +52,29 @@ $(function () { assert.ok(!/height/i.test($el.attr('style')), 'has height reset') }) + QUnit.test('should collapse only the first collapse', function (assert) { + assert.expect(2) + var html = [ + '