TabController: More sensible next tab auto-selection

This commit is contained in:
James Magahern
2021-02-15 18:54:32 -08:00
parent 97894f5d61
commit 6eb320bf7a
2 changed files with 6 additions and 6 deletions

View File

@@ -609,12 +609,8 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
}
func tabPicker(_ picker: TabPickerViewController, willCloseTab tab: Tab) {
// If closed tab is current tab, pick another one.
// Dismiss picker if current tab is closed using the picker
if tab == self.tab {
if let nextTab = tabController.tabs.last(where: { $0 != tab }) {
self.tab = nextTab
}
picker.dismiss(animated: true, completion: nil)
}
}

View File

@@ -43,7 +43,11 @@ class TabController
tabs.remove(at: index)
if tabs.count > 0 {
activeTabIndex = tabs.count - 1
if index < tabs.count {
activeTabIndex = index
} else {
activeTabIndex = tabs.count - 1
}
} else {
_ = createNewTab(url: nil)
activeTabIndex = 0