Skip to content

Commit 7690484

Browse files
committed
fix: remove tab instead of closing window when dropping active table
1 parent d942687 commit 7690484

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- DROP TABLE and TRUNCATE TABLE sidebar operations producing no SQL for plugin-based drivers
2929
- Foreign key navigation arrows not appearing after switching databases with Cmd+K on MySQL
3030
- Sidebar not refreshing after creating or dropping tables
31+
- Dropping a table disconnecting the database when the dropped table's tab was active
3132

3233
## [0.19.1] - 2026-03-16
3334

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,21 @@ extension MainContentCoordinator {
225225
}
226226

227227
if clearTableOps {
228-
// Close tabs for deleted tables
228+
// Remove tabs for deleted tables
229229
if !deletedTables.isEmpty {
230-
if let currentTab = tabManager.selectedTab,
231-
let tableName = currentTab.tableName,
232-
deletedTables.contains(tableName) {
233-
NSApp.keyWindow?.close()
230+
let tabIdsToRemove = Set(
231+
tabManager.tabs
232+
.filter { $0.tabType == .table && deletedTables.contains($0.tableName ?? "") }
233+
.map(\.id)
234+
)
235+
236+
if !tabIdsToRemove.isEmpty {
237+
tabManager.tabs.removeAll { tabIdsToRemove.contains($0.id) }
238+
if let firstRemaining = tabManager.tabs.first {
239+
tabManager.selectedTabId = firstRemaining.id
240+
} else {
241+
tabManager.selectedTabId = nil
242+
}
234243
}
235244
}
236245

0 commit comments

Comments
 (0)