0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-19 16:54:24 +01:00

Fix active class toggling of tabs within dropdown (#37151)

* Close #36947: fix active class toggling tabs within dropdown
This commit is contained in:
Carson Sievert 2022-09-21 18:29:58 -05:00 committed by GitHub
parent 27f20257eb
commit 2b46842af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

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

View File

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