mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
parent
2be9cd59ba
commit
1510c25e9b
@ -115,7 +115,6 @@ class Tab extends BaseComponent {
|
||||
return
|
||||
}
|
||||
|
||||
element.focus()
|
||||
element.removeAttribute('tabindex')
|
||||
element.setAttribute('aria-selected', true)
|
||||
this._toggleDropDown(element, true)
|
||||
|
@ -36,9 +36,7 @@ describe('Tab', () => {
|
||||
expect(tabBySelector._element).toEqual(tabEl)
|
||||
expect(tabByElement._element).toEqual(tabEl)
|
||||
})
|
||||
})
|
||||
|
||||
describe('constructor', () => {
|
||||
it('Do not Throw exception if not parent', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
fixtureEl.innerHTML = '<div class=""><div class="nav-link"></div></div>'
|
||||
@ -383,6 +381,35 @@ describe('Tab', () => {
|
||||
btnCloseEl.click()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not focus on opened tab', () => {
|
||||
return new Promise(resolve => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<ul class="nav" role="tablist">',
|
||||
' <li><button type="button" id="home" data-bs-target="#home" role="tab">Home</button></li>',
|
||||
' <li><button type="button" id="triggerProfile" data-bs-target="#profile" role="tab">Profile</button></li>',
|
||||
'</ul>',
|
||||
'<ul>',
|
||||
' <li id="home" role="tabpanel"></li>',
|
||||
' <li id="profile" role="tabpanel"></li>',
|
||||
'</ul>'
|
||||
].join('')
|
||||
|
||||
const firstTab = fixtureEl.querySelector('#home')
|
||||
firstTab.focus()
|
||||
|
||||
const profileTriggerEl = fixtureEl.querySelector('#triggerProfile')
|
||||
const tab = new Tab(profileTriggerEl)
|
||||
|
||||
profileTriggerEl.addEventListener('shown.bs.tab', () => {
|
||||
expect(document.activeElement).toBe(firstTab)
|
||||
expect(document.activeElement).not.toBe(profileTriggerEl)
|
||||
resolve()
|
||||
})
|
||||
|
||||
tab.show()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('dispose', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user