A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.
C++
fix(tabs): restore tab selection and navigation (#62)
Tobide12d3dbfaf4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3e63888..5d6fc33 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,11 @@All notable changes to Gridex are documented in this file. Gridex ships native apps for **macOS** (Swift/AppKit) and **Windows** (C++/WinUI 3). Unless noted otherwise, changes apply to both platforms.+## [Unreleased]++### Fixed+- **macOS tabs** — Clicking a tab reliably activates it; Control-Tab and Control-Shift-Tab cycle forward/backward; tab close controls retain their expected left/middle-click behavior.+## [0.23.0] - 2026-04-12### Addeddiff --git a/macos/App/Lifecycle/GridexApp.swift b/macos/App/Lifecycle/GridexApp.swiftindex c15b31b..38abcf2 100644--- a/macos/App/Lifecycle/GridexApp.swift+++ b/macos/App/Lifecycle/GridexApp.swift@@ -44,6 +44,14 @@ struct GridexApp: App {Divider()+ Button("Next Tab") { currentAppState?.selectNextTab() }+ .keyboardShortcut(.tab, modifiers: .control)+ .disabled((currentAppState?.tabs.count ?? 0) < 2)++ Button("Previous Tab") { currentAppState?.selectPreviousTab() }+ .keyboardShortcut(.tab, modifiers: [.control, .shift])+ .disabled((currentAppState?.tabs.count ?? 0) < 2)+Button("Close Tab") {currentAppState?.closeActiveTab()}diff --git a/macos/App/State/AppState.swift b/macos/App/State/AppState.swiftindex 8a8c57d..73db826 100644--- a/macos/App/State/AppState.swift+++ b/macos/App/State/AppState.swift@@ -539,6 +539,25 @@ final class AppState: ObservableObject {if let db = currentDatabaseName { ensureTabGroup(for: db) }}+ func selectTab(id: UUID) {+ guard tabs.contains(where: { $0.id == id }) else { return }+ activeTabId = id+ }++ func selectNextTab() {+ guard let activeTabId,+ let index = tabs.firstIndex(where: { $0.id == activeTabId }),+ tabs.count > 1 else { return }+ self.activeTabId = tabs[(index + 1) % tabs.count].id+ }++ func selectPreviousTab() {+ guard let activeTabId,+ let index = tabs.firstIndex(where: { $0.id == activeTabId }),+ tabs.count > 1 else { return }+ self.activeTabId = tabs[(index - 1 + tabs.count) % tabs.count].id+ }+func closeTab(id: UUID) {tabs.removeAll { $0.id == id }if let state = dataGridCache.removeValue(forKey: id) {diff --git a/macos/Presentation/Views/TabBar/TabBarSwiftUI.swift b/macos/Presentation/Views/TabBar/TabBarSwiftUI.swiftindex d0e2472..a31f470 100644--- a/macos/Presentation/Views/TabBar/TabBarSwiftUI.swift+++ b/macos/Presentation/Views/TabBar/TabBarSwiftUI.swift@@ -155,10 +155,10 @@ struct TabItemView: View {var body: some View {HStack(spacing: 7) {- Image(systemName: tabIcon)- .font(.system(size: 11))-if isRenaming {+ Image(systemName: tabIcon)+ .font(.system(size: 11))+TextField("", text: $renameText, onCommit: {let trimmed = renameText.trimmingCharacters(in: .whitespaces)if !trimmed.isEmpty {@@ -172,9 +172,17 @@ struct TabItemView: View {.onAppear { renameText = tab.title }.onExitCommand { isRenaming = false }} else {- Text(tab.title)- .font(.system(size: 12))- .lineLimit(1)+ Button(action: { appState.selectTab(id: tab.id) }) {+ HStack(spacing: 7) {+ Image(systemName: tabIcon)+ .font(.system(size: 11))++ Text(tab.title)+ .font(.system(size: 12))+ .lineLimit(1)+ }+ }+ .buttonStyle(.plain)}Button(action: { appState.closeTab(id: tab.id) }) {@@ -200,7 +208,6 @@ struct TabItemView: View {Divider().frame(height: 18)}.pointerCursor()- .onTapGesture { appState.activeTabId = tab.id }.overlay(MiddleClickOverlay { appState.closeTab(id: tab.id) }).onHover { isHovering = $0 }.contextMenu {@@ -278,17 +285,20 @@ class MiddleClickNSView: NSView {super.viewDidMoveToWindow()if window != nil, monitor == nil {monitor = NSEvent.addLocalMonitorForEvents(matching: .otherMouseDown) { [weak self] event in- guard let self, let action = self.action, event.buttonNumber == 2 else { return event }+ guard let self, event.buttonNumber == 2 else { return event }let locationInView = self.convert(event.locationInWindow, from: nil)- if self.bounds.contains(locationInView) {- action()- return nil- }- return event+ return self.handleMiddleClick(at: locationInView) ? nil : event}}}+ @discardableResult+ func handleMiddleClick(at point: NSPoint) -> Bool {+ guard bounds.contains(point), let action else { return false }+ action()+ return true+ }+override func removeFromSuperview() {if let monitor { NSEvent.removeMonitor(monitor) }monitor = nil