Skip to content

Commit 5d7ed17

Browse files
committed
Do not dismiss selector views after selection
1 parent 9e59c70 commit 5d7ed17

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

WooCommerce/Classes/ViewRelated/Filters/FilterListViewController.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ private extension FilterListViewController {
363363

364364
self?.updateUI(numberOfActiveFilters: self?.viewModel.filterTypeViewModels.numberOfActiveFilters ?? 0)
365365
self?.listSelector.reloadData()
366-
self?.listSelector.navigationController?.popViewController(animated: true)
367366
}
368367
)
369368
}()
@@ -381,7 +380,6 @@ private extension FilterListViewController {
381380
selected.selectedValue = resource
382381
self?.updateUI(numberOfActiveFilters: self?.viewModel.filterTypeViewModels.numberOfActiveFilters ?? 0)
383382
self?.listSelector.reloadData()
384-
self?.listSelector.navigationController?.popViewController(animated: true)
385383
}
386384
)
387385
let hostingController = UIHostingController(rootView: memberListSelectorView)
@@ -402,7 +400,6 @@ private extension FilterListViewController {
402400
}()
403401
self?.updateUI(numberOfActiveFilters: self?.viewModel.filterTypeViewModels.numberOfActiveFilters ?? 0)
404402
self?.listSelector.reloadData()
405-
self?.listSelector.navigationController?.popViewController(animated: true)
406403
}
407404
)
408405
let hostingController = UIHostingController(rootView: memberListSelectorView)

WooCommerce/Classes/ViewRelated/Orders/Order Creation/CustomerSection/CustomerSearchUICommand.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ final class CustomerSearchUICommand: SearchUICommand {
6565
private let hideDetailText: Bool
6666

6767
// The currently selected customer ID to show checkmark
68-
private let selectedCustomerID: Int64?
68+
private var selectedCustomerID: Int64?
6969

7070
init(siteID: Int64,
7171
loadResultsWhenSearchTermIsEmpty: Bool = false,
@@ -99,6 +99,10 @@ final class CustomerSearchUICommand: SearchUICommand {
9999
self.onDidFinishSyncingAllCustomersFirstPage = onDidFinishSyncingAllCustomersFirstPage
100100
}
101101

102+
func updateSelectedCustomerID(_ customerID: Int64?) {
103+
self.selectedCustomerID = customerID
104+
}
105+
102106
var hideCancelButton: Bool {
103107
featureFlagService.isFeatureFlagEnabled(.betterCustomerSelectionInOrder)
104108
}

WooCommerce/Classes/ViewRelated/Orders/Order Creation/CustomerSection/CustomerSelectorViewController.swift

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Yosemite
88
///
99
final class CustomerSelectorViewController: UIViewController, GhostableViewController {
1010
private var searchViewController: SearchViewController<UnderlineableTitleAndSubtitleAndDetailTableViewCell, CustomerSearchUICommand>?
11+
private var customerSearchCommand: CustomerSearchUICommand?
1112
private var emptyStateViewController: UIViewController?
1213
private let siteID: Int64
1314
private let onCustomerSelected: (Customer) -> Void
@@ -200,31 +201,34 @@ private extension CustomerSelectorViewController {
200201
shouldTrackCustomerAdded: Bool,
201202
disallowCreatingCustomer: Bool,
202203
onAddCustomerDetailsManually: (() -> Void)? = nil) {
204+
let command = CustomerSearchUICommand(siteID: siteID,
205+
loadResultsWhenSearchTermIsEmpty: loadResultsWhenSearchTermIsEmpty,
206+
showSearchFilters: showSearchFilters,
207+
showGuestLabel: showGuestLabel,
208+
shouldTrackCustomerAdded: shouldTrackCustomerAdded,
209+
disallowCreatingCustomer: disallowCreatingCustomer,
210+
hideDetailText: configuration.hideDetailText,
211+
selectedCustomerID: selectedCustomerID,
212+
onAddCustomerDetailsManually: onAddCustomerDetailsManually,
213+
onDidSelectSearchResult: onCustomerTapped,
214+
onDidStartSyncingAllCustomersFirstPage: {
215+
Task { @MainActor [weak self] in
216+
guard let searchTableView = self?.searchViewController?.tableView else {
217+
return
218+
}
219+
self?.displayGhostContent(over: searchTableView)
220+
}
221+
},
222+
onDidFinishSyncingAllCustomersFirstPage: {
223+
Task { @MainActor [weak self] in
224+
self?.removeGhostContent()
225+
}
226+
})
227+
self.customerSearchCommand = command
228+
203229
let searchViewController = SearchViewController(
204230
storeID: siteID,
205-
command: CustomerSearchUICommand(siteID: siteID,
206-
loadResultsWhenSearchTermIsEmpty: loadResultsWhenSearchTermIsEmpty,
207-
showSearchFilters: showSearchFilters,
208-
showGuestLabel: showGuestLabel,
209-
shouldTrackCustomerAdded: shouldTrackCustomerAdded,
210-
disallowCreatingCustomer: disallowCreatingCustomer,
211-
hideDetailText: configuration.hideDetailText,
212-
selectedCustomerID: selectedCustomerID,
213-
onAddCustomerDetailsManually: onAddCustomerDetailsManually,
214-
onDidSelectSearchResult: onCustomerTapped,
215-
onDidStartSyncingAllCustomersFirstPage: {
216-
Task { @MainActor [weak self] in
217-
guard let searchTableView = self?.searchViewController?.tableView else {
218-
return
219-
}
220-
self?.displayGhostContent(over: searchTableView)
221-
}
222-
},
223-
onDidFinishSyncingAllCustomersFirstPage: {
224-
Task { @MainActor [weak self] in
225-
self?.removeGhostContent()
226-
}
227-
}),
231+
command: command,
228232
cellType: UnderlineableTitleAndSubtitleAndDetailTableViewCell.self,
229233
cellSeparator: .none
230234
)
@@ -283,6 +287,8 @@ private extension CustomerSelectorViewController {
283287
viewModel.onCustomerSelected(customer, onCompletion: { [weak self] result in
284288
guard let self else { return }
285289
activityIndicator.stopAnimating()
290+
customerSearchCommand?.updateSelectedCustomerID(customer.customerID)
291+
searchViewController?.tableView.reloadData()
286292

287293
switch result {
288294
case .success:

0 commit comments

Comments
 (0)