Skip to content

Commit 7fed764

Browse files
committed
Cleanup orders navigation stack before pushing new order details
1 parent 2409e76 commit 7fed764

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,14 @@ private extension OrdersRootViewController {
366366
private func navigateToOrderDetail(_ order: Order) {
367367
guard let orderViewController = OrderDetailsViewController.instantiatedViewControllerFromStoryboard() else { return }
368368
orderViewController.viewModel = OrderDetailsViewModel(order: order)
369-
show(orderViewController, sender: self)
369+
370+
// Cleanup navigation (remove new order flow views) before navigating to order details
371+
if let navigationController = navigationController, let indexOfSelf = navigationController.viewControllers.firstIndex(of: self) {
372+
let viewControllersIncludingSelf = navigationController.viewControllers[0...indexOfSelf]
373+
navigationController.setViewControllers(viewControllersIncludingSelf + [orderViewController], animated: true)
374+
} else {
375+
show(orderViewController, sender: self)
376+
}
370377

371378
ServiceLocator.analytics.track(.orderOpen, withProperties: ["id": order.orderID, "status": order.status.rawValue])
372379
}

0 commit comments

Comments
 (0)