Fix for render issue for tabs
This commit is contained in:
parent
89870edaaf
commit
df95905fe0
@ -31,8 +31,7 @@ const waitForElement = (selector) => {
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
init: (container = document, spacer = true, args = {}) => {
|
||||
export function init(container = document, spacer = true, args = {}) {
|
||||
|
||||
container.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
||||
|
||||
@ -52,7 +51,8 @@ module.exports = {
|
||||
tabPanel.setAttribute("aria-labelledby", `tab-${tabgroup}-${tabID}`);
|
||||
tabPanel.appendChild(child.cloneNode(true));
|
||||
child.parentNode.replaceChild(tabPanel, child);
|
||||
tablist += `<li tabindex="0" role="tab" ${tablist === "" ? "class='selected'" : ""} id="tab-${tabgroup}-${tabID}"><span>${tab}</span></li>`;
|
||||
let cls = tablist === "" ? "class='selected'" : "";
|
||||
tablist += `<li tabindex="0" role="tab" ${cls}="" id="tab-${tabgroup}-${tabID}"><span>${tab}</span></li>`;
|
||||
} else {
|
||||
child.classList.add("tab-hidden");
|
||||
}
|
||||
@ -64,13 +64,13 @@ module.exports = {
|
||||
tabGroup.insertBefore(ul, tabGroup.firstChild);
|
||||
|
||||
tabGroup.querySelectorAll('[role="tab"]').forEach(tab => {
|
||||
tab.addEventListener("click", (e) => {
|
||||
if (e.altKey && typeof args.altModifier == "function") {
|
||||
args.altModifier(tab);
|
||||
} else if (e.shiftKey && typeof args.shiftModifier == "function") {
|
||||
args.shiftModifier(tab);
|
||||
} else if (e.metaKey && typeof args.metaModifier == "function") {
|
||||
args.metaModifier(tab);
|
||||
tab.addEventListener("click", (evt) => {
|
||||
if (evt.altKey && typeof args.altModifier == "function") {
|
||||
args.altModifier(tab, evt);
|
||||
} else if (evt.shiftKey && typeof args.shiftModifier == "function") {
|
||||
args.shiftModifier(tab, evt);
|
||||
} else if (evt.metaKey && typeof args.metaModifier == "function") {
|
||||
args.metaModifier(tab, evt);
|
||||
} else {
|
||||
const siblings = Array.from(tab.parentNode.children);
|
||||
siblings.forEach(sibling => sibling.classList.remove("selected"));
|
||||
@ -101,8 +101,6 @@ module.exports = {
|
||||
el.focus();
|
||||
el.dispatchEvent(click);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user