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:
parent
27f20257eb
commit
2b46842af9
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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')
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user