Skip to content

Commit 7fabba7

Browse files
committed
fix: select nearest neighbor tab after dropping a table
1 parent 7690484 commit 7fabba7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

TablePro/Views/Main/Extensions/MainContentCoordinator+SaveChanges.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,12 @@ extension MainContentCoordinator {
234234
)
235235

236236
if !tabIdsToRemove.isEmpty {
237+
let firstRemovedIndex = tabManager.tabs
238+
.firstIndex { tabIdsToRemove.contains($0.id) } ?? 0
237239
tabManager.tabs.removeAll { tabIdsToRemove.contains($0.id) }
238-
if let firstRemaining = tabManager.tabs.first {
239-
tabManager.selectedTabId = firstRemaining.id
240+
if !tabManager.tabs.isEmpty {
241+
let neighborIndex = min(firstRemovedIndex, tabManager.tabs.count - 1)
242+
tabManager.selectedTabId = tabManager.tabs[neighborIndex].id
240243
} else {
241244
tabManager.selectedTabId = nil
242245
}

0 commit comments

Comments
 (0)