Skip to content

Commit 358e207

Browse files
committed
Update trait change handling in ProductFormViewController
1 parent a608254 commit 358e207

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
168168
observeUpdateCTAVisibility()
169169
observeVariationsPriceChanges()
170170
observeUpdateBlazeEligibility()
171+
observeTraitChanges()
171172

172173
productImageStatusesSubscription = productImageActionHandler.addUpdateObserver(self) { [weak self] productImageStatuses in
173174
guard let self = self else {
@@ -203,12 +204,6 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
203204
return true
204205
}
205206

206-
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
207-
super.traitCollectionDidChange(previousTraitCollection)
208-
209-
updateNavigationBarTitle()
210-
}
211-
212207
// MARK: - Navigation actions handling
213208

214209
override func shouldPopOnBackButton() -> Bool {
@@ -949,6 +944,16 @@ private extension ProductFormViewController {
949944
self?.displayImageUploadErrorAlert(error: error, for: asset)
950945
})
951946
}
947+
948+
func observeTraitChanges() {
949+
let traits: [UITrait] = [
950+
UITraitHorizontalSizeClass.self,
951+
UITraitVerticalSizeClass.self
952+
]
953+
registerForTraitChanges(traits) { (self: Self, _) in
954+
self.updateNavigationBarTitle()
955+
}
956+
}
952957
}
953958

954959
// MARK: More details actions

0 commit comments

Comments
 (0)