Allow returning from global search with the escape key

cmd+k jumps to the search tab but left users with no way back. Pressing
escape in the search field now returns to the tab they came from (never
into search itself).

Escape is handled at the search field's pressesBegan, alongside the
existing arrow-key navigation, since the focused UIKit field swallows
SwiftUI keyboard shortcuts.
This commit is contained in:
Stefan Ceriu
2026-06-22 16:22:57 +03:00
parent a04a4c2691
commit c5653c2208
7 changed files with 44 additions and 4 deletions
@@ -33,6 +33,8 @@ struct SearchScreenViewModelTests {
switch action {
case .presentRoom(let roomID):
roomID == "2"
case .cancel:
false
}
}
@@ -40,4 +42,20 @@ struct SearchScreenViewModelTests {
try await deferred.fulfill()
}
@Test
func cancel() async throws {
let deferred = deferFulfillment(viewModel.actionsPublisher) { action in
switch action {
case .cancel:
true
default:
false
}
}
context.send(viewAction: .cancel)
try await deferred.fulfill()
}
}