File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
firefox-ios/Client/TabManagement Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,9 @@ class TabManagerImplementation: NSObject,
246246
247247 func removeAllTabs( isPrivateMode: Bool ) {
248248 let currentModeTabs = tabs. filter { $0. isPrivate == isPrivateMode }
249+ guard !currentModeTabs. isEmpty else { return }
249250 var currentSelectedTab : BackupCloseTab ?
251+ let previouslySelectedTab = selectedTab
250252
251253 // Backup the selected tab in separate variable as the `removeTab` method called below for each tab will
252254 // automatically update tab selection as if there was a single tab removal.
@@ -258,7 +260,15 @@ class TabManagerImplementation: NSObject,
258260 backupCloseTabs = tabs
259261
260262 for tab in currentModeTabs {
261- self . removeTab ( tab. tabUUID)
263+ removeTab ( tab, flushToDisk: false )
264+ }
265+
266+ if let selectedTabBackup = currentSelectedTab {
267+ let deletedIndex = selectedTabBackup. restorePosition ?? selectedIndex
268+ updateSelectedTabAfterRemovalOf ( selectedTabBackup. tab, deletedIndex: deletedIndex)
269+ } else if let previousTab = previouslySelectedTab,
270+ tabs. contains ( where: { $0 === previousTab } ) {
271+ selectTab ( previousTab, previous: previousTab)
262272 }
263273
264274 // Save the tab state that existed prior to removals (preserves original selected tab)
You can’t perform that action at this time.
0 commit comments