Focus the project dashboard when ⌘P opens it

This commit is contained in:
Ian Gulliver
2026-10-21 22:38:16 -07:00
parent 4f2c0def94
commit 5384c83a0f
3 changed files with 16 additions and 0 deletions
+13
View File
@@ -8,8 +8,10 @@ private let refreshKinds: Set<String> = ["task.merged", "project.created"]
struct ProjectView: View {
@Environment(Store.self) private var store
@Environment(Overlays.self) private var overlays
@ViewState private var todos: [String: Result<Todo, ApiError>] = [:]
@ViewState private var off: (() -> Void)?
@FocusState private var focused: Bool
var body: some View {
ScrollView {
@@ -23,6 +25,17 @@ struct ProjectView: View {
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.focusable()
.focusEffectDisabled()
.focused($focused)
.onChange(of: overlays.projectFocus, initial: true) {
if overlays.projectFocus {
overlays.projectFocus = false
DispatchQueue.main.async {
focused = true
}
}
}
.onAppear {
off = store.events.add { ev in
if refreshKinds.contains(ev.kind), let projectId = ev.projectId {