Skip to content

Commit

Permalink
Fix brave/brave-ios#7851: Tab selection for TabsBar interface is done…
Browse files Browse the repository at this point in the history
… after active website is loaded (brave/brave-ios#8032)
  • Loading branch information
soner-yuksel committed Sep 6, 2023
1 parent 71756cd commit 034d193
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 034d193

Please sign in to comment.