From 88d0ea34bfd34ab2df5df93394a976668a7ef3bf Mon Sep 17 00:00:00 2001 From: diath Date: Wed, 26 Aug 2020 09:54:56 +0200 Subject: [PATCH] Fix UITabBar and UIMoveableTabBar bricking when removing first tabs in (#1101) collapsed view Co-authored-by: Xagul --- modules/corelib/ui/uimovabletabbar.lua | 5 ++++- modules/corelib/ui/uitabbar.lua | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/corelib/ui/uimovabletabbar.lua b/modules/corelib/ui/uimovabletabbar.lua index d4991cc0..284588ca 100644 --- a/modules/corelib/ui/uimovabletabbar.lua +++ b/modules/corelib/ui/uimovabletabbar.lua @@ -334,9 +334,12 @@ function UIMoveableTabBar:removeTab(tab) end if self.currentTab == tab then - self:selectPrevTab() if #self.tabs == 1 then self.currentTab = nil + elseif index == #self.tabs then + self:selectPrevTab() + else + self:selectNextTab() end end table.remove(tabTable, index) diff --git a/modules/corelib/ui/uitabbar.lua b/modules/corelib/ui/uitabbar.lua index 951692f9..e593fc0c 100644 --- a/modules/corelib/ui/uitabbar.lua +++ b/modules/corelib/ui/uitabbar.lua @@ -77,7 +77,13 @@ function UITabBar:removeTab(tab) local index = table.find(self.tabs, tab) if index == nil then return end if self.currentTab == tab then - self:selectPrevTab() + if #self.tabs == 1 then + self.currentTab = nil + elseif index == #self.tabs then + self:selectPrevTab() + else + self:selectNextTab() + end end table.remove(self.tabs, index) tab:destroy()