Picker keyboard focus

This commit is contained in:
Ian Gulliver
2026-10-21 10:13:31 -07:00
parent 9afe016b06
commit 1ab0ebad9f
2 changed files with 17 additions and 2 deletions
+12 -1
View File
@@ -77,7 +77,8 @@ private let shortcuts: [(String, [(String, String)])] = [
("Esc", "Close the switcher or a dialog"),
]),
("Task switcher", [
("Tab / Shift+Tab", "Move the highlight"),
("Tab", "Switch between the text and the list"),
("↑ ↓", "Move the highlight, in the list"),
("Enter", "Pick the highlighted row"),
("Shift+Enter", "New line in the first message"),
("name: message", "Start the task in the project whose name starts with name"),
@@ -153,6 +154,7 @@ final class SwitcherModel {
let imageKey = "switcher:\(UUID().uuidString)"
var text = ""
var selected = 0
var inList = false
var workflows: [WorkflowSummary] = []
init(store: Store, overlays: Overlays, anchor: CGRect) {
@@ -389,6 +391,7 @@ private struct SwitcherBox: View {
.padding(.vertical, 6)
.frame(maxWidth: .infinity, alignment: .leading)
.background(i == selected ? Palette.accentTint : .clear, in: RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(i == selected && model.inList ? Palette.accent : .clear))
.contentShape(Rectangle())
.onTapGesture {
model.pick(row)
@@ -421,6 +424,14 @@ private struct SwitcherBox: View {
}
}
}
.onChange(of: model.inList) {
focused = !model.inList
}
.onChange(of: focused) {
if focused {
model.inList = false
}
}
}
private var editor: some View {