Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tabs not directly managing content #366

Merged
merged 2 commits into from
May 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export class Tabs extends Component {
// Update the variables with the new link and content

this._activeTabLink = tabLink;
this._content = document.querySelector(tabLink.hash);
if (tabLink.hash)
this._content = document.querySelector(tabLink.hash);
this._tabLinks = this.el.querySelectorAll('li.tab > a');
// Make the tab active
this._activeTabLink.classList.add('active');
Expand Down Expand Up @@ -160,8 +161,8 @@ export class Tabs extends Component {
this._activeTabLink.classList.add('active');

this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
if (this._activeTabLink) {
this._content = document.querySelector(this._activeTabLink.hash);
if (this._activeTabLink && this._activeTabLink.hash) {
this._content = document.querySelector(this._activeTabLink.hash);
wuda-io marked this conversation as resolved.
Show resolved Hide resolved
this._content.classList.add('active');
}
}
Expand All @@ -173,9 +174,11 @@ export class Tabs extends Component {

const tabsContent = [];
this._tabLinks.forEach(a => {
const currContent = document.querySelector(a.hash);
currContent.classList.add('carousel-item');
tabsContent.push(currContent);
if (a.hash) {
const currContent = document.querySelector(a.hash);
currContent.classList.add('carousel-item');
tabsContent.push(currContent);
}
});

// Create Carousel-Wrapper around Tab-Contents
Expand Down