Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarson Sievert <cpsievert1@gmail.com>2022-09-22 02:29:58 +0300
committerGitHub <noreply@github.com>2022-09-22 02:29:58 +0300
commit2b46842af908fe54bd7f7982ed07c7cd07bc934a (patch)
treeb03b1fe46bf710f544c5ae218d09b919c87eadb8
parent27f20257ebd092b2e5d11a62de0cd5e9cf5a9949 (diff)
Fix active class toggling of tabs within dropdown (#37151)
* Close #36947: fix active class toggling tabs within dropdown
-rw-r--r--js/src/tab.js2
-rw-r--r--js/tests/unit/tab.spec.js7
2 files changed, 4 insertions, 5 deletions
diff --git a/js/src/tab.js b/js/src/tab.js
index 31dcec4a4b..1d6d68d85c 100644
--- a/js/src/tab.js
+++ b/js/src/tab.js
@@ -38,7 +38,6 @@ const CLASS_DROPDOWN = 'dropdown'
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
const SELECTOR_DROPDOWN_MENU = '.dropdown-menu'
-const SELECTOR_DROPDOWN_ITEM = '.dropdown-item'
const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)'
const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]'
@@ -231,7 +230,6 @@ class Tab extends BaseComponent {
toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE)
toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW)
- toggle(SELECTOR_DROPDOWN_ITEM, CLASS_NAME_ACTIVE)
outerElem.setAttribute('aria-expanded', open)
}
diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js
index 15d5811736..b00014eed0 100644
--- a/js/tests/unit/tab.spec.js
+++ b/js/tests/unit/tab.spec.js
@@ -840,10 +840,11 @@ describe('Tab', () => {
'</ul>'
].join('')
- const firstDropItem = fixtureEl.querySelector('.dropdown-item')
+ const dropItems = fixtureEl.querySelectorAll('.dropdown-item')
- firstDropItem.click()
- expect(firstDropItem).toHaveClass('active')
+ dropItems[1].click()
+ expect(dropItems[0]).not.toHaveClass('active')
+ expect(dropItems[1]).toHaveClass('active')
expect(fixtureEl.querySelector('.nav-link')).not.toHaveClass('active')
})