File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
WooCommerce/Classes/Tools/Notices Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ class DefaultNoticePresenter: NoticePresenter {
2020 ///
2121 private var noticeOnScreen : Notice ?
2222
23+ var kvoToken : NSKeyValueObservation ?
24+
2325 /// UIViewController to be used as Notice(s) Presenter
2426 ///
2527 weak var presentingViewController : UIViewController ?
@@ -191,6 +193,7 @@ private extension DefaultNoticePresenter {
191193 func dismiss( ) {
192194 noticeOnScreen = nil
193195 keyboardFrameObserver = nil
196+ kvoToken = nil
194197 presentNextNoticeIfPossible ( )
195198 }
196199
@@ -207,7 +210,20 @@ private extension DefaultNoticePresenter {
207210 fatalError ( " NoticePresenter requires a presentingViewController! " )
208211 }
209212
210- if let tabBarController = presentingViewController as? UITabBarController {
213+ if let tabBarController = presentingViewController as? UITabBarController ,
214+ !tabBarController. tabBar. isHidden {
215+ if kvoToken == nil {
216+ kvoToken = tabBarController. tabBar. observe ( \. isHidden, options: . new) { tabBar, _ in
217+ guard tabBar. isHidden else {
218+ return
219+ }
220+
221+ // If the tab bar hides we also hide the notice, as trying to rearrange the notice accordingly might bring unexpected results
222+ // due to the internal logic of UITabBarController e.g they remove/recreate the tab bar when navigation happens
223+ container. isHidden = true
224+ }
225+ }
226+
211227 return container. bottomAnchor. constraint ( equalTo: tabBarController. tabBar. topAnchor)
212228 }
213229
You can’t perform that action at this time.
0 commit comments