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

[tabs] Ensure only one tab is ever active (issue 472) #474

Merged
merged 19 commits into from May 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/components/tabs.vue
Expand Up @@ -183,10 +183,12 @@
return;
}

// Deactivate previous active tab
if (this.tabs[this.currentTab]) {
this.$set(this.tabs[this.currentTab], 'localActive', false);
}
// Deactivate any previous active tab(s)
this.tabs.forEach( t => {
if (t !== tab && t.active) {
this.$set(t, 'localActive', false);
}
});

// Set new tab as active
this.$set(tab, 'localActive', true);
Expand All @@ -212,10 +214,11 @@
this.$set(tab, 'lazy', this.lazy);
});

// Set initial active tab
// Get initial active tab
let tabIndex = this.currentTab;

if (this.currentTab === null || this.currentTab === undefined) {
if (tabIndex === null || tabIndex === undefined) {
// Find last active tab in current tabs
this.tabs.forEach((tab, index) => {
if (tab.active) {
tabIndex = index;
Expand Down