Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #7851: Tab selection for TabsBar interface is done after active w…
Browse files Browse the repository at this point in the history
…ebsite is loaded (#8032)
  • Loading branch information
soner-yuksel authored Sep 6, 2023
1 parent 739ca11 commit 041dc88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,8 @@ public class BrowserViewController: UIViewController {
}
searchController?.additionalSafeAreaInsets = additionalInsets
favoritesController?.additionalSafeAreaInsets = additionalInsets

tabsBar.reloadDataAndRestoreSelectedTab(isAnimated: false)
}

override public var canBecomeFirstResponder: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ extension BrowserViewController: WKNavigationDelegate {
// Set rewards inter site url as new page load url.
rewardsXHRLoadURL = webView.url
}

tabsBar.reloadDataAndRestoreSelectedTab()

if tab.walletEthProvider != nil {
tab.emitEthereumEvent(.connect)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,23 @@ class TabsBarViewController: UIViewController {
}
}

func reloadDataAndRestoreSelectedTab() {
func reloadDataAndRestoreSelectedTab(isAnimated: Bool? = nil) {
collectionView.reloadData()

guard let tabManager = tabManager, let selectedTabIndex = selectedTabIndexPath else {
return
}

var scrollTabsBarAnimated = !tabManager.isRestoring

if let isAnimated = isAnimated {
scrollTabsBarAnimated = isAnimated
}

if selectedTabIndex.row < tabList.count() {
collectionView.selectItem(
at: selectedTabIndex,
animated: (!tabManager.isRestoring),
animated: scrollTabsBarAnimated,
scrollPosition: .centeredHorizontally)
}
}
Expand Down

0 comments on commit 041dc88

Please sign in to comment.