Fix Enter in the merge dialog
This commit is contained in:
@@ -61,6 +61,7 @@ final class Overlays {
|
||||
@ObservationIgnored weak var window: NSWindow?
|
||||
@ObservationIgnored private var monitor: Any?
|
||||
@ObservationIgnored private var mouseMonitor: Any?
|
||||
@ObservationIgnored private weak var behindModal: NSResponder?
|
||||
@ObservationIgnored private var holders = 0
|
||||
@ObservationIgnored private var ctrl: @MainActor (String) -> Bool = { _ in false }
|
||||
|
||||
@@ -85,6 +86,11 @@ final class Overlays {
|
||||
func showModal(_ content: some View, _ buttons: @autoclosure @escaping @MainActor () -> [ModalButton], anchor: CGRect? = nil, inPane: Bool = false, canSubmit: @escaping @MainActor () -> Bool = { true }) async -> String {
|
||||
modal?.done("cancel")
|
||||
menu = nil
|
||||
if modal == nil {
|
||||
let responder = window?.firstResponder
|
||||
behindModal = (responder as? NSTextView).flatMap { $0.isFieldEditor ? $0.delegate as? NSResponder : nil } ?? responder
|
||||
window?.makeFirstResponder(nil)
|
||||
}
|
||||
return await withCheckedContinuation { cont in
|
||||
modal = OverlayModal(content: AnyView(content), buttons: buttons, anchor: anchor, inPane: inPane, canSubmit: canSubmit) { value in
|
||||
cont.resume(returning: value)
|
||||
@@ -104,6 +110,10 @@ final class Overlays {
|
||||
func answerModal(_ value: String) {
|
||||
let m = modal
|
||||
modal = nil
|
||||
if let behindModal, window?.firstResponder !== behindModal {
|
||||
window?.makeFirstResponder(behindModal)
|
||||
}
|
||||
behindModal = nil
|
||||
m?.done(value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user