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()