diff --git a/js/src/dropdown.js b/js/src/dropdown.js index c064c3461a..f38712e476 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -436,6 +436,10 @@ class Dropdown { toggles[i].setAttribute('aria-expanded', 'false') + if (context._popper) { + context._popper.destroy() + } + $(dropdownMenu).removeClass(ClassName.SHOW) $(parent) .removeClass(ClassName.SHOW) diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 85ebc0ed25..07702e2f62 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -799,7 +799,7 @@ $(function () { .parent('.dropdown') .on('shown.bs.dropdown', function () { // Forcibly focus first item - $item.focus() + $item[0].focus() assert.ok($(document.activeElement)[0] === $item[0], 'menu item initial focus set') // Key escape @@ -1506,4 +1506,48 @@ $(function () { assert.strictEqual(popperConfig.placement, 'left') }) + + QUnit.test('should destroy old popper references on toggle', function (assert) { + assert.expect(3) + var done = assert.async() + + var fixtureHtml = [ + '