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

Commit

Permalink
Fix #3041: TabTray is not being dismissed when actual controller is n…
Browse files Browse the repository at this point in the history
…ot TabTray but Data is inserted to indexpaths (#3049)
  • Loading branch information
soner-yuksel authored Nov 18, 2020
1 parent 6881727 commit e90bee9
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Client/Frontend/Browser/TabTrayController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -663,18 +663,14 @@ extension TabTrayController: TabManagerDelegate {
}

tabDataSource.addTab(tab)
if navigationController?.visibleViewController === self {
self.collectionView?.performBatchUpdates({
self.collectionView.insertItems(at: [IndexPath(item: index, section: 0)])
}, completion: { finished in
if finished {
tabManager.selectTab(tab)
// don't pop the tab tray view controller if it is not in the foreground
if self.presentedViewController == nil {
_ = self.navigationController?.popViewController(animated: true)
}

insertTabToCollection(tab, index: index) {
if let controller = self.navigationController?.visibleViewController, controller is TabTrayController {
// don't pop the tab tray view controller if it is not in the foreground
if self.presentedViewController == nil {
_ = self.navigationController?.popViewController(animated: true)
}
})
}
}
}

Expand Down Expand Up @@ -712,6 +708,18 @@ extension TabTrayController: TabManagerDelegate {
})
}
}

private func insertTabToCollection(_ tab: Tab, index: Int, completion: @escaping () -> Void ) {
collectionView?.performBatchUpdates({
self.collectionView.insertItems(at: [IndexPath(item: index, section: 0)])
}, completion: { finished in
if finished {
self.tabManager.selectTab(tab)

completion()
}
})
}
}

extension TabTrayController: UIScrollViewAccessibilityDelegate {
Expand Down

0 comments on commit e90bee9

Please # to comment.