diff --git a/CHANGELOG.md b/CHANGELOG.md index f447677b9..72e023f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Opening a query tab no longer pulls keyboard focus away from the sidebar or another control; the editor takes focus only when nothing else holds it. VoiceOver now labels the SQL editor and the Clear and Format buttons. (#1490) - The connection form opens with the Name field focused, Return or the Down arrow in the welcome search moves to the connection list, and focus returns to the list after a sheet closes, so you can set up a connection without the mouse. (#1490) - Escape now dismisses search-based sheets and popovers (database switcher, quick switcher, column and connection pickers). Pressing Escape clears the search text first; a second Escape closes the sheet. (#1490) - Running `EXPLAIN` or `EXPLAIN ANALYZE` typed in the editor now opens the plan viewer instead of squashing the plan into one truncated grid cell. (#1480) diff --git a/TablePro/Views/Editor/QueryEditorView.swift b/TablePro/Views/Editor/QueryEditorView.swift index 211d45a4b..747548cca 100644 --- a/TablePro/Views/Editor/QueryEditorView.swift +++ b/TablePro/Views/Editor/QueryEditorView.swift @@ -100,6 +100,7 @@ struct QueryEditorView: View { } .buttonStyle(.borderless) .help(String(localized: "Clear Query")) + .accessibilityLabel(String(localized: "Clear Query")) // Format button Button(action: formatQuery) { @@ -108,6 +109,7 @@ struct QueryEditorView: View { } .buttonStyle(.borderless) .help(String(localized: "Format Query (⇧⌘L)")) + .accessibilityLabel(String(localized: "Format Query")) .optionalKeyboardShortcut(AppSettingsManager.shared.keyboard.keyboardShortcut(for: .formatQuery)) Divider() diff --git a/TablePro/Views/Editor/SQLEditorCoordinator.swift b/TablePro/Views/Editor/SQLEditorCoordinator.swift index a1ab80011..6a5636658 100644 --- a/TablePro/Views/Editor/SQLEditorCoordinator.swift +++ b/TablePro/Views/Editor/SQLEditorCoordinator.swift @@ -110,7 +110,8 @@ final class SQLEditorCoordinator: TextViewCoordinator, TextViewDelegate { // Auto-focus: make the editor first responder, then ensure a // cursor exists. Order matters — setCursorPositions calls // updateSelectionViews which guards on isFirstResponder. - if !self.isDestroyed, let window = textView.window { + if !self.isDestroyed, let window = textView.window, + window.firstResponder == nil || window.firstResponder === window { window.makeFirstResponder(textView) } if controller.cursorPositions.isEmpty { diff --git a/TablePro/Views/Editor/SQLEditorView.swift b/TablePro/Views/Editor/SQLEditorView.swift index 0b17a9199..2ab428046 100644 --- a/TablePro/Views/Editor/SQLEditorView.swift +++ b/TablePro/Views/Editor/SQLEditorView.swift @@ -63,6 +63,7 @@ struct SQLEditorView: View { coordinators: [coordinator], completionDelegate: completionAdapter ) + .accessibilityLabel(String(localized: "SQL query editor")) .onChange(of: editorState.cursorPositions) { _, newValue in guard let positions = newValue else { return } // Skip cursor propagation when the editor doesn't have focus