Fix UITabBar and UIMoveableTabBar bricking when removing first tabs in (#1101) collapsed view

Co-authored-by: Xagul <eixim@hotmail.com>
This commit is contained in:
diath
2020-08-26 09:54:56 +02:00
committed by GitHub
parent b3aaa10646
commit 88d0ea34bf
2 changed files with 11 additions and 2 deletions

View File

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

View File

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