Skip to content

Commit

Permalink
Fix initial isPressed registration in KeyboardShortcutsExample
Browse files Browse the repository at this point in the history
The `isPressed` indicator was not changing for shortcuts created
with the `DynamicShortcutRecorder`. This was caused by registration
having been done with `.onChange(of:_:)` - where `action` is only
evaluated with the first change of the value. Specify `initial` so
that it is evaluated on appearance as well.
  • Loading branch information
cweider committed Nov 30, 2024
1 parent c3c361f commit bce3609
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Example/KeyboardShortcutsExample/MainScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private struct DynamicShortcut: View {
.frame(maxWidth: 300)
.padding()
.padding(.bottom, 20)
.onChange(of: shortcut) { oldValue, newValue in
.onChange(of: shortcut, initial: true) { oldValue, newValue in
onShortcutChange(oldValue: oldValue, newValue: newValue)
}
}
Expand Down

0 comments on commit bce3609

Please sign in to comment.