From 2313ad45919be9cbc1577604c972c9c1c0959788 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 1 Jan 2022 18:41:26 +0100 Subject: [PATCH] Added tabs management comments --- .../kotlin/app/ui/components/RepositoriesTabPanel.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt b/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt index 7bae14a..377d3fb 100644 --- a/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt +++ b/src/main/kotlin/app/ui/components/RepositoriesTabPanel.kt @@ -57,13 +57,13 @@ fun RepositoriesTabPanel( val isTabSelected = selectedTabKey == tab.key val index = tabs.indexOf(tab) val nextIndex = if (index == 0 && tabs.count() >= 2) { - 1 + 1 // If the first tab is selected, select the next one } else if (index == tabs.count() -1 && tabs.count() >= 2) - index - 1 + index - 1 // If the last tab is selected, select the previous one else if (tabs.count() >= 2) - index + index // If any in between tab is selected, select the next one else - -1 + -1 // If there aren't any additional tabs once we remove this one val nextKey = if (nextIndex >= 0) tabs[nextIndex].key @@ -76,8 +76,9 @@ fun RepositoriesTabPanel( } else { tabsIdentifier++ - onTabSelected(tabsIdentifier) + // Create a new tab if the tabs list is empty after removing the current one newTabContent(tabsIdentifier) + onTabSelected(tabsIdentifier) } }