-
-
Notifications
You must be signed in to change notification settings - Fork 298
fix(datagrid): move focus to grid on explicit table open (#1490) #1497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,17 @@ extension MainContentCoordinator { | |
| _ table: TableInfo, | ||
| showStructure: Bool = false, | ||
| redirectToSibling: Bool = false, | ||
| forceNonPreview: Bool = false | ||
| forceNonPreview: Bool = false, | ||
| activateGridFocus: Bool = false | ||
| ) { | ||
| openTableTab( | ||
| table.name, | ||
| schema: table.schema, | ||
| showStructure: showStructure, | ||
| isView: table.type == .view, | ||
| redirectToSibling: redirectToSibling, | ||
| forceNonPreview: forceNonPreview | ||
| forceNonPreview: forceNonPreview, | ||
| activateGridFocus: activateGridFocus | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -37,7 +39,8 @@ extension MainContentCoordinator { | |
| showStructure: Bool = false, | ||
| isView: Bool = false, | ||
| redirectToSibling: Bool = false, | ||
| forceNonPreview: Bool = false | ||
| forceNonPreview: Bool = false, | ||
| activateGridFocus: Bool = false | ||
| ) { | ||
| let navigationModel = PluginMetadataRegistry.shared.snapshot( | ||
| forTypeId: connection.type.pluginTypeId | ||
|
|
@@ -65,9 +68,16 @@ extension MainContentCoordinator { | |
| if showStructure, let (_, tabIndex) = tabManager.selectedTabAndIndex { | ||
| tabManager.mutate(at: tabIndex) { $0.display.resultsViewMode = .structure } | ||
| } | ||
| if activateGridFocus { | ||
| focusActiveGrid() | ||
| } | ||
| return | ||
| } | ||
|
|
||
| if activateGridFocus { | ||
| pendingGridFocusOnOpen = true | ||
| } | ||
|
|
||
| // During database switch, update the existing tab in-place instead of | ||
| // opening a new native window tab. | ||
| if case .loading = SchemaService.shared.state(for: connectionId) { | ||
|
|
@@ -82,6 +92,8 @@ extension MainContentCoordinator { | |
| } catch { | ||
| navigationLogger.error("openTableTab addTableTab failed: \(error.localizedDescription, privacy: .public)") | ||
| } | ||
| } else { | ||
| pendingGridFocusOnOpen = false | ||
| } | ||
| return | ||
| } | ||
|
|
@@ -102,6 +114,7 @@ extension MainContentCoordinator { | |
| guard hasMatch, | ||
| let windowId = sibling.windowId, | ||
| let window = WindowLifecycleMonitor.shared.window(for: windowId) else { continue } | ||
| pendingGridFocusOnOpen = false | ||
| window.makeKeyAndOrderFront(nil) | ||
|
Comment on lines
+117
to
118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the quick switcher opens a table that already exists in another window, this branch clears the focus request on the current coordinator and only raises the sibling window. Because no grid is attached in the current window and the sibling coordinator is never asked to focus its grid, the sibling window keeps whatever first responder it previously had (for example the editor or sidebar), so arrow keys still do not navigate the selected table after this explicit open. Useful? React with 👍 / 👎. |
||
| return | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,7 +112,7 @@ struct SidebarContextMenu: View { | |
| Button("Show Structure") { | ||
| perform { | ||
| if let clickedTable { | ||
| coordinator?.openTableTab(clickedTable, showStructure: true) | ||
| coordinator?.openTableTab(clickedTable, showStructure: true, activateGridFocus: true) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this path opens the Structure view, the rendered Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When preview tabs are enabled and an explicit open reuses the currently selected preview table tab, this only sets
pendingGridFocusOnOpen, thenreuseActiveTabmutates the same tab in place. The existingDataGridViewis not remounted in that path, soKeyHandlingTableView.viewDidMoveToWindow()does not run to consume the pending flag, leaving focus in the sidebar after double-click/Return on a different table in the preview tab. This path needs to focus the attached grid (or otherwise consume the pending intent) after reusing the tab.Useful? React with 👍 / 👎.