         // No tab
         guard let tab = tabManager.selectedTab else {
             navigationToolbar.updateMiddleButtonState(.search)
+            currentMiddleButtonState = .search
             return
         }
         
         // Tab with starting page
         if tab.isURLStartingPage {
             navigationToolbar.updateMiddleButtonState(.search)
+            currentMiddleButtonState = .search
             return
         }
         
         let state: MiddleButtonState = shouldShowNewTabButton ? .newTab : (isLoading ? .stop : .reload)
         navigationToolbar.updateMiddleButtonState(state)
+        currentMiddleButtonState = state
     }
 
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {

    lazy var mailtoLinkHandler = MailtoLinkHandler()
    var urlFromAnotherApp: UrlToOpenModel?
    var isCrashAlertShowing: Bool = false
    
    fileprivate var customSearchBarButton: UIBarButtonItem?

    // popover rotation handling

            toolbar?.applyUIMode(isPrivate: tabManager.selectedTab?.isPrivate ?? false)
            toolbar?.applyTheme()
            toolbar?.addNewTabButton.isHidden = true
            // This is for showing (+) add tab middle button with A/B test where we need to update both toolbar and url bar when (+) button is enabled.
            // Urlbar already has reader mode state but we still need to refresh it so that if reader mode is available we don't accidently show reload or stop button in url bar
            if shouldShowNewTabButton {
                toolbar?.updateMiddleButtonState(.newTab)
                let state = urlBar.locationView.readerModeState
                urlBar.updateReaderModeState(state)
            } else {
                toolbar?.updateMiddleButtonState(currentMiddleButtonState ?? .search)
            }
            updateTabCountUsingTabManager(self.tabManager)
        }

