From 20d4959ae702433d0ed3626cc11ed75bb1bf0196 Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Tue, 21 Nov 2023 17:21:25 -0500 Subject: [PATCH] Fix #8457: Only update toolbar layout when actually required --- .../Browser/BrowserViewController.swift | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 4e7b3614c3d..53cc827e27f 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -625,25 +625,25 @@ public class BrowserViewController: UIViewController { fileprivate func updateToolbarStateForTraitCollection(_ newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator? = nil) { let showToolbar = shouldShowFooterForTraitCollection(newCollection) - - topToolbar.setShowToolbar(!showToolbar) - toolbar?.removeFromSuperview() - toolbar?.tabToolbarDelegate = nil - toolbar = nil - bottomTouchArea.isEnabled = showToolbar - - if showToolbar { - toolbar = BottomToolbarView(privateBrowsingManager: privateBrowsingManager) - toolbar?.setSearchButtonState(url: tabManager.selectedTab?.url) - footer.addSubview(toolbar!) - toolbar?.tabToolbarDelegate = self - toolbar?.menuButton.setBadges(Array(topToolbar.menuButton.badges.keys)) + if (showToolbar && toolbar == nil) || (!showToolbar && toolbar != nil) { + topToolbar.setShowToolbar(!showToolbar) + toolbar?.removeFromSuperview() + toolbar?.tabToolbarDelegate = nil + toolbar = nil + bottomTouchArea.isEnabled = showToolbar + + if showToolbar { + toolbar = BottomToolbarView(privateBrowsingManager: privateBrowsingManager) + toolbar?.setSearchButtonState(url: tabManager.selectedTab?.url) + footer.addSubview(toolbar!) + toolbar?.tabToolbarDelegate = self + toolbar?.menuButton.setBadges(Array(topToolbar.menuButton.badges.keys)) + } + updateToolbarUsingTabManager(tabManager) + updateUsingBottomBar(using: newCollection) + + view.setNeedsUpdateConstraints() } - updateToolbarUsingTabManager(tabManager) - updateUsingBottomBar(using: newCollection) - - view.setNeedsUpdateConstraints() - if let tab = tabManager.selectedTab, let webView = tab.webView { updateURLBar()