Fix keyboard escape key not working for cancelling edits and replies on the Mac

This commit is contained in:
Stefan Ceriu
2024-05-09 14:32:34 +03:00
committed by Stefan Ceriu
parent 783eab2a8a
commit 45ac47ce16
2 changed files with 12 additions and 1 deletions
@@ -103,7 +103,7 @@ struct GlobalSearchScreen: View {
Button("") { Button("") {
context.send(viewAction: .dismiss) context.send(viewAction: .dismiss)
} }
// Need this to enable escape on the textfield and forward the presses // Need this to enable escape on the textField and forward the presses
.keyboardShortcut(.escape, modifiers: []) .keyboardShortcut(.escape, modifiers: [])
} }
} }
@@ -30,6 +30,7 @@ struct MessageComposerTextField: View {
pasteHandler: pasteHandler) pasteHandler: pasteHandler)
.accessibilityLabel(placeholder) .accessibilityLabel(placeholder)
.background(placeholderView, alignment: .topLeading) .background(placeholderView, alignment: .topLeading)
.background { keyboardShortcuts }
} }
@ViewBuilder @ViewBuilder
@@ -41,6 +42,16 @@ struct MessageComposerTextField: View {
.accessibilityHidden(true) .accessibilityHidden(true)
} }
} }
private var keyboardShortcuts: some View {
Group {
Button("") {
keyHandler(.keyboardEscape)
}
// Need this to enable escape on the textView and forward the presses
.keyboardShortcut(.escape, modifiers: [])
}
}
} }
private struct UITextViewWrapper: UIViewRepresentable { private struct UITextViewWrapper: UIViewRepresentable {