Skip to content

Commit b5a5c71

Browse files
committed
Ensure tabListSlot is display block if its the role=tablist
By default tabListSlot is `display:contents` which can cause a couple of issues: 1. Some browsers don't expose role information for elements that are display:contents, and so this makes an inaccessible component. 2. Depending on how the tabs are styled, they can end up in weird orientations due to the tablist having no layout. Making it have a layout with display:block fixes this.
1 parent 7d5ed41 commit b5a5c71

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/tab-container-element.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,14 @@ export class TabContainerElement extends HTMLElement {
186186

187187
selectTab(index: number): void {
188188
if (!this.#setup) {
189+
const tabListSlot = this.#tabListSlot;
189190
const customTabList = this.querySelector('[role=tablist]')
190191
if (customTabList && customTabList.closest(this.tagName) === this) {
191-
this.#tabListSlot.assign(customTabList)
192+
tabListSlot.assign(customTabList)
192193
} else {
193-
this.#tabListSlot.assign(...[...this.children].filter(e => e.matches('[role=tab]')))
194-
this.#tabListSlot.role = 'tablist'
194+
tabListSlot.assign(...[...this.children].filter(e => e.matches('[role=tab]')))
195+
tabListSlot.role = 'tablist'
196+
tabListSlot.style.display = 'block'
195197
}
196198
const tabList = this.#tabList
197199
if (this.hasAttribute('aria-description')) {

0 commit comments

Comments
 (0)