Skip to content

Add "close other tabs" button to tab page menu. - #6799

Open
and0p wants to merge 1 commit into
wikimedia:mainfrom
and0p:close-other-tabs
Open

Add "close other tabs" button to tab page menu.#6799
and0p wants to merge 1 commit into
wikimedia:mainfrom
and0p:close-other-tabs

Conversation

@and0p

@and0p and0p commented Aug 16, 2026

Copy link
Copy Markdown

What does this do?

Adds a "close other tabs" button to the tab page menu:

Screenshot_20260815_225121 Screenshot_20260815_225156 Screenshot_20260815_225205

Tested and working on Android 16. Undo works as expected.

Did not add integration tests as ArticleTabTest seems to be broken by explore feed changes at the moment. I may try to address that in a separate PR and update this one.

I have only added strings in English.

Why is this needed?

The Phabricator ticket has a good summary.

I have also been wanting this for a couple years. I often find myself opening a Wikipedia link, seeing that I have 70+ tabs open, and then not being able to close them all without also losing the page I am on.

(It might also be nice to have this in the toolbar when looking at the article itself, but then it would need to make sense with the "customize toolbar" feature that allows actions to be pinned to the bottom of the screen at all times.)

Phabricator:
https://phabricator.wikimedia.org/T395550

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a “Close other tabs” action to preserve the active article while removing other open tabs.

Changes:

  • Adds menu and confirmation UI strings.
  • Removes all inactive tabs and updates the tab list.
  • Provides an Undo snackbar restoring closed tabs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
strings.xml Adds action, confirmation, and feedback strings.
menu_tabs.xml Adds the new overflow-menu item.
TabActivity.kt Implements tab removal and Undo behavior.
Suppressed comments (1)

app/src/main/java/org/wikipedia/page/tabs/TabActivity.kt:202

  • The insertion position assumes the retained tab is still present. While this snackbar is visible, the user can close that last tab and then tap this Undo action; the adapter then has zero items, so notifying an insertion starting at position 1 can trigger RecyclerView inconsistency/IndexOutOfBounds errors. Capture the current adapter item count before restoring the tabs and use it as the insertion position (normally 1, but 0 after the retained tab was closed).
                binding.tabRecyclerView.adapter?.notifyItemRangeInserted(1, otherTabs.size)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

openNewTab()
true
}
R.id.menu_close_other_tabs -> {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants