commit 2dd391544161c9b2f94cf68207b6d2c9ec4a20b1
parent 5c43b0031d153c642b04bac5856d067d66bdcee4
Author: Michael Camilleri <[email protected]>
Date: Sun, 15 Mar 2026 05:27:46 +0900
Fix focus bug in macOS version
Prior to this commit, pressing Command-N would not give focus to the
newly created row on macOS. This commit fixes that.
Co-Authored-By: Claude 4.6 Opus <[email protected]>
Diffstat:
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ListlessMac/Extensions/TaskListView+Toolbar.swift b/ListlessMac/Extensions/TaskListView+Toolbar.swift
@@ -25,8 +25,6 @@ extension TaskListView {
Button {
createNewTask()
- // Trigger focus resolution by setting to nil
- focusedField = nil
} label: {
Label("New Item", systemImage: "plus")
}
diff --git a/ListlessMac/Views/TaskListView.swift b/ListlessMac/Views/TaskListView.swift
@@ -110,7 +110,7 @@ struct TaskListView: View, TaskListViewProtocol {
func updateMenuCoordinator() {
let coord = menuCoordinator
- coord.newTask = { createNewTask(); focusedField = nil }
+ coord.newTask = { createNewTask() }
coord.copySelectedTask = {
guard let taskID = fState.selectedTaskID,
let task = tasks.first(where: { $0.id == taskID }) else { return }
diff --git a/Tests/UI/ListlessMacUITests.swift b/Tests/UI/ListlessMacUITests.swift
@@ -80,6 +80,22 @@ final class ListlessMacUITests: XCTestCase {
// MARK: - Task Creation
+ func testCmdNFocusesDraftField() {
+ app.typeKey("n", modifierFlags: .command)
+ let textField = draftTextField
+ XCTAssertTrue(
+ textField.waitForExistence(timeout: 2),
+ "Draft text field should appear after Cmd+N"
+ )
+ // Type directly without clicking — verifies the field has focus
+ textField.typeText("Focused item")
+ textField.typeKey(.return, modifierFlags: [])
+ XCTAssertTrue(
+ taskText("Focused item").waitForExistence(timeout: 2),
+ "Typing without clicking should commit the task if draft field has focus"
+ )
+ }
+
func testCreateTaskViaMenuShortcut() {
createTask("Buy groceries")
XCTAssertTrue(