File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
WooCommerce/Classes/ViewRelated/Orders/Order Creation Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ final class NewOrderHostingController: UIHostingController<NewOrder> {
4444///
4545extension NewOrderHostingController {
4646 override func shouldPopOnBackButton( ) -> Bool {
47- guard !viewModel. hasChanges else {
47+ guard viewModel . canBeDismissed || !viewModel. hasChanges else {
4848 presentDiscardChangesActionSheet ( onDiscard: { [ weak self] in
4949 self ? . discardOrderAndPop ( )
5050 } )
@@ -62,7 +62,7 @@ extension NewOrderHostingController {
6262///
6363extension NewOrderHostingController : UIAdaptivePresentationControllerDelegate {
6464 func presentationControllerShouldDismiss( _ presentationController: UIPresentationController ) -> Bool {
65- return !viewModel. hasChanges
65+ return viewModel . canBeDismissed || !viewModel. hasChanges
6666 }
6767
6868 func presentationControllerDidAttemptToDismiss( _ presentationController: UIPresentationController ) {
Original file line number Diff line number Diff line change @@ -28,7 +28,18 @@ final class NewOrderViewModel: ObservableObject {
2828 /// Indicates whether user has made any changes
2929 ///
3030 var hasChanges : Bool {
31- orderSynchronizer. order != OrderFactory . emptyNewOrder && flow == . creation
31+ switch flow {
32+ case . creation:
33+ return orderSynchronizer. order != OrderFactory . emptyNewOrder
34+ case . editing( let initialOrder) :
35+ return orderSynchronizer. order != initialOrder
36+ }
37+ }
38+
39+ /// Indicates whether view can be dismissed. If the value is `false` - confirmation alert will be displayd depending on `hasChanges` value.
40+ ///
41+ var canBeDismissed : Bool {
42+ flow == . creation
3243 }
3344
3445 /// Indicates whether the cancel button is visible.
You can’t perform that action at this time.
0 commit comments