Skip to content

Commit 8e5903a

Browse files
committed
Fixes for modal alerts and sheets dismissal, making them async
Hopefully final fixes for model mutation while rendering
1 parent 0334b5b commit 8e5903a

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

ActionUI/Common/WindowModalView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@ struct WindowModalView: SwiftUI.View {
7474
private var sheetBinding: Binding<WindowModal?> {
7575
Binding(
7676
get: { windowModel.windowModal?.style == .sheet ? windowModel.windowModal : nil },
77-
set: { if $0 == nil { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } }
77+
set: { if $0 == nil { DispatchQueue.main.async { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } } }
7878
)
7979
}
8080

8181
private var fullCoverBinding: Binding<WindowModal?> {
8282
Binding(
8383
get: { windowModel.windowModal?.style == .fullScreenCover ? windowModel.windowModal : nil },
84-
set: { if $0 == nil { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } }
84+
set: { if $0 == nil { DispatchQueue.main.async { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } } }
8585
)
8686
}
8787
#else
8888
// macOS: both sheet and fullScreenCover styles use the single .sheet modifier
8989
private var anyModalBinding: Binding<WindowModal?> {
9090
Binding(
9191
get: { windowModel.windowModal },
92-
set: { if $0 == nil { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } }
92+
set: { if $0 == nil { DispatchQueue.main.async { ActionUIModel.shared.dismissModal(windowUUID: windowUUID) } } }
9393
)
9494
}
9595
#endif
@@ -107,14 +107,14 @@ struct WindowModalView: SwiftUI.View {
107107
private var alertBinding: Binding<Bool> {
108108
Binding(
109109
get: { windowModel.windowDialog?.style == .alert },
110-
set: { if !$0 { ActionUIModel.shared.dismissDialog(windowUUID: windowUUID) } }
110+
set: { if !$0 { DispatchQueue.main.async { ActionUIModel.shared.dismissDialog(windowUUID: windowUUID) } } }
111111
)
112112
}
113113

114114
private var confirmationBinding: Binding<Bool> {
115115
Binding(
116116
get: { windowModel.windowDialog?.style == .confirmationDialog },
117-
set: { if !$0 { ActionUIModel.shared.dismissDialog(windowUUID: windowUUID) } }
117+
set: { if !$0 { DispatchQueue.main.async { ActionUIModel.shared.dismissDialog(windowUUID: windowUUID) } } }
118118
)
119119
}
120120

0 commit comments

Comments
 (0)