From 95ee8789041bb41c632a6475b38ca5350df917b9 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:52:26 +0100 Subject: [PATCH 1/2] macOS: add test case for search bar focus change --- .../GhosttyMouseStateTests.swift | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/macos/GhosttyUITests/GhosttyMouseStateTests.swift b/macos/GhosttyUITests/GhosttyMouseStateTests.swift index 9bb270b8e..b8f202617 100644 --- a/macos/GhosttyUITests/GhosttyMouseStateTests.swift +++ b/macos/GhosttyUITests/GhosttyMouseStateTests.swift @@ -49,5 +49,39 @@ final class GhosttyMouseStateTests: GhosttyCustomConfigCase { XCTAssertEqual(NSPasteboard.general.string(forType: .string), nil, "Moving mouse shouldn't select any texts") } + + @MainActor func testSearchFocusState() async throws { + let app = try ghosttyApplication() + app.activate() + XCTAssertTrue(app.windows.firstMatch.waitForExistence(timeout: 5), "New window should appear") + app.typeKey("f", modifierFlags: .command) + + let textfield = app.textFields.firstMatch + XCTAssertTrue(textfield.waitForExistence(timeout: 5), "Search field should appear") + app.typeText("a") + + XCTAssertTrue(textfield.stringValue == "a", "Search text should be `a`") + + textfield.coordinate(withNormalizedOffset: .zero) + .withOffset(.init(dx: textfield.frame.width * 0.5, dy: 0)) + .click() + + app.typeText("b") + + XCTAssertTrue(textfield.stringValue == "ab", "Search text should be `ab`") + + // resign + app.typeKey(.escape, modifierFlags: []) + + // dismiss + app.typeKey(.escape, modifierFlags: []) + + XCTAssertTrue(textfield.waitForNonExistence(timeout: 5), "Search field should disappear") + } } +private extension XCUIElement { + var stringValue: String? { + (value as? String) + } +} From ad0c5fbec3e23f0e414ba3ebed1181f42000cfdb Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:53:12 +0100 Subject: [PATCH 2/2] macOS: fix regression caused by 3ee8ef4f650f550698ee1e8e81e591511e195bf4 --- macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index 2289a3bdd..8f4fb01cf 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -667,7 +667,9 @@ extension Ghostty { // The clicked location in this window should be this view. let location = convert(event.locationInWindow, from: nil) - guard hitTest(location) == self else { return event } + // We should use window to perform hitTest here, + // because there could be some other overlays on top, like search bar + guard window.contentView?.hitTest(location) == self else { return event } // We always assume that we're resetting our mouse suppression // unless we see the specific scenario below to set it.