Skip to content

feat: Return to previous tab when closing tabs#11933

Merged
mr-cheffy merged 2 commits into
zen-browser:devfrom
Anodev-sudo:dev
Jan 17, 2026
Merged

feat: Return to previous tab when closing tabs#11933
mr-cheffy merged 2 commits into
zen-browser:devfrom
Anodev-sudo:dev

Conversation

@Anodev-sudo
Copy link
Copy Markdown
Contributor

Removes the zen-newtab guard that prevents owner tab assignment when a new tab is created via hotkey or url bar. Closing a new tab will now return to the tab it was opened from.



Previously, closing these tabs would jump to the first regular tab instead of returning to the opener.

Ownership will not be assigned if multiple background tabs are created, but this matches current behavior. Single background tabs or newly created tabs will have ownership.

My testing hasn’t shown any other changes in behavior.

Fixes #11775

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. Bug labels Jan 17, 2026
Copy link
Copy Markdown
Member

@mr-cheffy mr-cheffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is a hacky solution since you are simply allowing ALL tabs to have an owner (meaning you can close them, for example, with the back button, which is not what tab.owner is supposed to do).

Also, tab.owner might get cleared in some cases such as when opening a new background tab from the recently opened tab.

I think the fix rests around the _findtabtoblur (https://searchfox.org/firefox-main/source/browser/components/tabbrowser/content/tabbrowser.js#5859) function, where the next tab should be decided based on the last accessed time

lastAccessed time will be used to select the active tab instead of positional selection or ownership when a tab is closed, returning the user to their last used tab.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 17, 2026
@Anodev-sudo
Copy link
Copy Markdown
Contributor Author

I removed the previous changes. Now, lastAccessed will be used to determine the last active tab, which will be switched to on tab close.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 17, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jan 17, 2026
@mr-cheffy mr-cheffy merged commit ceb5405 into zen-browser:dev Jan 17, 2026
1 check passed
@mr-cheffy mr-cheffy changed the title fix: Return to previous tab when closing tabs feat: Return to previous tab when closing tabs Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closing Tab Does Not Go To Previous Tab for Pinned tabs

2 participants