Repository navigation
fix(windows): keep every window's key view loop current so Tab reaches each pane - #2916
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2904.
Root cause
TabWindowController.makeEditorWindow()leftNSWindow.autorecalculatesKeyViewLoopat its default offalse, andMainSplitViewController.viewWillAppearcomputed the key view loop exactly once. Every pane in a connection window is anNSHostingControllerinstalled into aWorkspacePaneHost, and SwiftUI builds its content later still, so nothing on the detail side ever entered the loop.SidebarContainerViewControllerpapered over one hop of it by hand, assigningsearchField.nextKeyViewon everyshow(), which was the only reason the filter field could reach its own list.The reported symptom was the small half. Measured on the shipping Debug build, driven through the accessibility API (macOS 27, Full Keyboard Access off, a SQLite connection with a table tab open):
Tabfrom the sidebar filtersidebar-filter-> object list -> connections rail ->sidebar-filter, a closed 3-stop cycleTabstopCtrl+F6So
TabandDowninto the list already worked, anddocs/features/keyboard-shortcuts.mdxalready documentedDown. What did not work was leaving the sidebar at all. A keyboard-only user could not reach the editor or the grid.Reproduced in a compiled AppKit harness of the same shape (
NSWindow->NSSplitViewController->WorkspacePaneHost->NSHostingController->NSViewRepresentable->NSScrollView->NSOutlineView, panes installed after the window is on screen):outline.nextValidKeyViewis nil and the tab walk is dead.window.recalculateKeyViewLoop()after the panes exist repairs it to Outline -> Grid -> editor.autorecalculatesKeyViewLoop = trueat window creation, with no explicit recalculate anywhere, produces the correct loop and keeps it correct across a pane swap, which is what a connection or tab switch does.The fix
One property replaces three mechanisms.
NSWindow.keepsKeyViewLoopCurrent()setsautorecalculatesKeyViewLoop = true, and the one-shotrecalculateKeyViewLoop()plus both hand-maintainedsearchField.nextKeyViewassignments are gone. A recalculation discards an explicitnextKeyViewanyway, measured, so keeping them meant two mechanisms fighting over one link.It is not one window. Every window TablePro builds programmatically had the same defect and now carries the same line: the connection window, the connection form, Welcome, Settings, Compare & Sync, the inspector, the value viewer, What's New, and the three simple windows built through
NSWindow.titled. The connection form is the most keyboard-heavy screen in the app.Cost, measured: on a 636-view window, 200 rounds of adding and removing a subview took 98.6ms with the property off and 81.6ms with it on. AppKit coalesces the recalculation rather than running one per subview change. This mattered because of the
NSTableViewsubview-churn invariant in CLAUDE.md, where one layout pass cost 518ms.A
View > Focussubmenu, extending the one focus command the app already had:Ctrl+Option+Cmd+F(unchanged)Ctrl+Option+Cmd+LCtrl+Option+Cmd+ECtrl+Option+Cmd+RCtrl+Option+Cmd+ICtrl+Option+Cmd+AEach reveals its pane before focusing it, because
makeFirstResponderaccepts a hidden view and reports success. Each dims when the pane it names is not there. The target is found in the selected workspace's own pane subtree rather than tracked:EditorEventRouteris window-scoped and returns an arbitrary editor when several are registered, so a window hosting several connections would have focused the wrong one.No "Move Focus to Next Area" command. There is no macOS system shortcut for moving focus between panes inside a window. Read from the macOS 27 system table
DefaultShortcutsTable.xml, sectionkeyboardnavigation, key 97 (F6) with modifier 262144 is "Move focus to the floating window", not "next pane".Tabis the mechanism, and it is what this change repairs.Also in this PR
MainSplitViewController+MenuValidation.isEnabledended indefault: return truewith no arm forclearSelection, and nothing forced a new menu item to have an arm, so the new Focus commands would have shipped permanently enabled with a green suite.isEnabledis nowresolvedEnablement -> Bool?(nil means the window does not own the command) withisEnabledpreserving the old?? truebehaviour, so no existing caller or test changed.MenuValidationCoverageTestsfails if any command the window owns lacks an arm.That guard found a second pre-existing gap while it was being written:
zoomIn:andzoomOut:had no arm either. Both now have explicit ones.Tests
EditorWindowChromeTests: the real window frommakeEditorWindow()keeps its key view loop current. This is the regression guard for the root cause.MenuValidationCoverageTests: every command the window owns is decided rather than left enabled by default;clearSelectionneeds a connection; each Focus command follows its own pane's readiness.NSViewDescendantsTests: the subtree searches, including that the key-view search skips whatTabskips.FocusCommandMenuTests: the submenu's contents, shortcuts, identifiers and shared modifier.WindowFocusUITests: each Focus command moves focus;Tabreaches the object list;Tabreaches the data grid outside the sidebar.WindowFocusUITestscompiles and its runner launches, but it could not be executed on this machine: every XCUITest run fails withTimed out while enabling automation mode, which is an unanswered macOS UI-automation prompt. An untouched control suite (ConnectionWindowChromeUITests) fails identically, so this is the environment and not the suite. It needs a run on CI or on an unlocked machine.Verification
Build PASS · 96/96 unit tests PASS ·
docs/scripts/check-writing-style.shPASS ·docs/scripts/check-docs-against-source.pyPASS ·swiftlint --strictclean over every changed file except one pre-existingtype_body_lengthviolation inMainContentCommandActions.swift, which is byte-identical tomain.Reviewed by Codex, which found seven issues. All were acted on. The one worth naming: the docs draft claimed
Shift+Tableaves the SQL editor, andTextViewController.handleTabreturns nil forShift+Tabunconditionally, so it always outdents and never reaches the key view loop. That would have shipped a documented shortcut that cannot work.