From 52397034883d27909524637f2255bccfbe1b9340 Mon Sep 17 00:00:00 2001 From: RafaelKayumov Date: Fri, 7 Nov 2025 17:50:06 +0300 Subject: [PATCH 1/3] Re-present the existing order details view controller --- .../OrderDetailsViewController.swift | 8 +++++++ .../Orders/OrderListViewController.swift | 9 +++++-- .../Orders/OrdersRootViewController.swift | 5 +++- .../OrdersSplitViewWrapperController.swift | 24 +++++++++++-------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift index c749ee1efc1..a9819af346e 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/OrderDetailsViewController.swift @@ -110,6 +110,14 @@ final class OrderDetailsViewController: UIViewController { override var shouldShowOfflineBanner: Bool { true } + + func isPresentingViewModelOrder(_ viewModel: OrderDetailsViewModel) -> Bool { + return self.viewModel.order.orderID == viewModel.order.orderID + } + + func isQuickOrderNavigationSupported() -> Bool { + viewModels.count > 1 + } } // MARK: - TableView Configuration diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift index 474b4e80646..9b9f876d460 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift @@ -626,8 +626,13 @@ extension OrderListViewController { /// Adds ability to select any order /// Used when opening an order with deep link /// - Parameter orderID: ID of the order to select in the list. + /// - Parameter isTriggeredByUserAction: Reflects if the order selection was triggered by a manual user action and not a view lifecycle update + /// Practically if the `isTriggeredByUserAction` is true, then the order details will be force presented even if `selectedOrderID` is the same as the new `orderID` /// - Returns: Whether the order to select is in the list already (i.e. the order has been fetched and exists locally). - func selectOrderFromListIfPossible(for orderID: Int64) -> Bool { + func selectOrderFromListIfPossible( + for orderID: Int64, + isTriggeredByUserAction: Bool = false, + ) -> Bool { guard let dataSource else { return false } @@ -637,7 +642,7 @@ extension OrderListViewController { let orderNotAlreadySelected = selectedOrderID != orderID let indexPath = dataSource.indexPath(for: identifier) let indexPathNotAlreadySelected = selectedIndexPath != indexPath - let shouldSwitchDetails = orderNotAlreadySelected || indexPathNotAlreadySelected + let shouldSwitchDetails = orderNotAlreadySelected || indexPathNotAlreadySelected || isTriggeredByUserAction if shouldSwitchDetails { showOrderDetails(detailsViewModel.order) } diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift index 066971cdc8c..9bc073c922d 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrdersRootViewController.swift @@ -165,7 +165,10 @@ final class OrdersRootViewController: UIViewController { /// - Returns: Whether the order to select is in the list already (i.e. the order has been fetched and exists locally). @discardableResult func selectOrderFromListIfPossible(for orderID: Int64) -> Bool { - ordersViewController.selectOrderFromListIfPossible(for: orderID) + ordersViewController.selectOrderFromListIfPossible( + for: orderID, + isTriggeredByUserAction: true + ) } /// Called when an order is shown externally (outside of `OrderListViewController`) and the order should be diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift index f65ca2a9895..2db1da53fdc 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrdersSplitViewWrapperController.swift @@ -129,10 +129,12 @@ private extension OrdersSplitViewWrapperController { // shown should replace the topViewController, to avoid having to tap back through several Order Details // screens in the navigation stack. The back button should always go to the Order List. // The up and down arrows are enabled when there is more than one item in `viewModels`. - guard isQuickOrderNavigationSupported(viewModels: viewModels), - let viewModel = viewModels[safe: currentIndex], - let secondaryNavigationController = ordersSplitViewController.viewController(for: .secondary) as? UINavigationController, - secondaryNavigationController.topViewController is OrderDetailsViewController else { + guard + let viewModel = viewModels[safe: currentIndex], + let secondaryNavigationController = ordersSplitViewController.viewController(for: .secondary) as? UINavigationController, + let existingOrderDetailsViewController = secondaryNavigationController.topViewController as? OrderDetailsViewController, + existingOrderDetailsViewController.isQuickOrderNavigationSupported() == orderDetailsViewController.isQuickOrderNavigationSupported() + else { // When showing an order without quick navigation, it simply sets the order details to the secondary view. let orderDetailsNavigationController = WooNavigationController(rootViewController: orderDetailsViewController) showSecondaryView(orderDetailsNavigationController) @@ -140,15 +142,17 @@ private extension OrdersSplitViewWrapperController { return } - secondaryNavigationController.replaceTopViewController(with: orderDetailsViewController, animated: false) - ordersViewController.onOrderSelected(id: viewModel.order.orderID) + if !existingOrderDetailsViewController.isPresentingViewModelOrder(viewModel) { + secondaryNavigationController.replaceTopViewController( + with: orderDetailsViewController, + animated: false + ) + ordersViewController.onOrderSelected(id: viewModel.order.orderID) + } + ordersSplitViewController.show(.secondary) onCompletion?(true) } - - func isQuickOrderNavigationSupported(viewModels: [OrderDetailsViewModel]) -> Bool { - viewModels.count > 1 - } } private extension OrdersSplitViewWrapperController { From 92f45f2f99aa34da7563e2166fa9f6196ecfee2d Mon Sep 17 00:00:00 2001 From: RafaelKayumov Date: Fri, 7 Nov 2025 18:54:21 +0300 Subject: [PATCH 2/3] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 608ae7dadc9..0ac51839b78 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,7 @@ - [**] We added support for collecting in-person payments (including Tap To Pay) using Stripe Payment Gateway extension in the UK. [https://github.com/woocommerce/woocommerce-ios/pull/16287] - [*] Improve card payments onboarding error handling to show network errors correctly [https://github.com/woocommerce/woocommerce-ios/pull/16304] - [*] Authenticate the admin page automatically for sites with SSO enabled in custom fields, in-person payment setup, and editing tax rates flows. [https://github.com/woocommerce/woocommerce-ios/pull/16318] +- [*] Fix order details presentation when opened from booking details [https://github.com/woocommerce/woocommerce-ios/pull/16331] 23.6 ----- From 79bf3565396f75aeb7dda619af79b9d53b3525ba Mon Sep 17 00:00:00 2001 From: RafaelKayumov Date: Fri, 7 Nov 2025 18:57:42 +0300 Subject: [PATCH 3/3] Fix line length violation --- .../Classes/ViewRelated/Orders/OrderListViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift index 9b9f876d460..1a2d1c8f955 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift @@ -627,7 +627,8 @@ extension OrderListViewController { /// Used when opening an order with deep link /// - Parameter orderID: ID of the order to select in the list. /// - Parameter isTriggeredByUserAction: Reflects if the order selection was triggered by a manual user action and not a view lifecycle update - /// Practically if the `isTriggeredByUserAction` is true, then the order details will be force presented even if `selectedOrderID` is the same as the new `orderID` + /// Practically if the `isTriggeredByUserAction` is true, then the order details will be force presented + /// even if `selectedOrderID` is the same as the new `orderID` /// - Returns: Whether the order to select is in the list already (i.e. the order has been fetched and exists locally). func selectOrderFromListIfPossible( for orderID: Int64,