From 51777efe217b7aced9609e771fc996179bff2456 Mon Sep 17 00:00:00 2001 From: Thomas Brouard Date: Tue, 1 Nov 2016 10:13:56 +0100 Subject: [PATCH] Fix tabs activation --- index.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 6eab1c8..3897f4c 100644 --- a/index.js +++ b/index.js @@ -57,12 +57,8 @@ class TabGroup { let id = this.newTabId; this.newTabId++; let tab = new Tab(this, id, args); - this.pushTab(tab); - return tab; - } - - pushTab (tab) { this.tabs.push(tab); + return tab; } removeTab (tab) { @@ -77,18 +73,17 @@ class TabGroup { setActiveTab (tab) { this.removeTab(tab); - this.pushTab(tab); + this.tabs.unshift(tab); } getActiveTab () { - if (this.tabs.length < 1) return null; - return this.tabs[this.tabs.length - 1]; + if (this.tabs.length === 0) return null; + return this.tabs[0]; } activateRecentTab (tab) { - let recentTab = this.tabs[this.tabs.length - 1]; - if (!recentTab) return; - recentTab.activate(); + if (this.tabs.length === 0) return null; + this.tabs[0].activate(); } }