Skip to content

web: Open new tabs beside the current one by extension#23313

Open
pzhlkj6612 wants to merge 1 commit into
ruffle-rs:masterfrom
pzhlkj6612:feat/open-new-tabs-beside-current-one
Open

web: Open new tabs beside the current one by extension#23313
pzhlkj6612 wants to merge 1 commit into
ruffle-rs:masterfrom
pzhlkj6612:feat/open-new-tabs-beside-current-one

Conversation

@pzhlkj6612
Copy link
Copy Markdown

Hello! Thanks for maintaining Ruffle. I can't always go back to my childhood to play old games without your hard work.

The logic about opening new tabs in the browser extension can be improved. I have so many tabs open. New ones opened by Ruffle always go to the end of the looooong tab list. I asked AI and have modified the code to let new tabs open beside the current one.

I'm not able to test the "onboard.html" page because I can't find a way to trigger the "INSTALL" event with unpacked extension. In Firefox Nightly, installing XPI file with setting xpinstall.signatures.required to false does not work. I can't figure it out.

The two changes about "player.html" have been tested, though.

Here is the commit message:

* Changes:
    * Open new tabs beside the current tab instead of at default position (after all tabs).
    * Remove redundant "promisify" wrapper from "tabs.create" calls.
* Test Environment:
    * Windows 11, Firefox 143.0.
    * Windows 11, Chrome 146.0.7680.80.

Please review, thank you!

* Changes:
    * Open new tabs beside the current tab instead of at default position (after all tabs).
    * Remove redundant "promisify" wrapper from "tabs.create" calls.
* Test Environment:
    * Windows 11, Firefox 143.0.
    * Windows 11, Chrome 146.0.7680.80.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pzhlkj6612 <29089388+pzhlkj6612@users.noreply.github.com>
@danielhjacobs danielhjacobs added A-web Area: Web & Extensions extension Related to the Ruffle WebExtension T-feature Type: New Feature (that Flash doesn't have) labels Mar 22, 2026
@kjarosh kjarosh added the llm The PR contains mostly LLM-generated code label Apr 4, 2026
Copy link
Copy Markdown
Collaborator

@evilpie evilpie left a comment

Choose a reason for hiding this comment

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

Instead of setting the index, you should set the openerTabId to the right tab. In Firefox at least this will automatically open the new tab after the current tab. This behaviour is actually controllable by the user using the about:config preference browser.tabs.insertRelatedAfterCurrent.

@pzhlkj6612 pzhlkj6612 marked this pull request as draft April 11, 2026 09:14
@pzhlkj6612
Copy link
Copy Markdown
Author

Instead of setting the index, you should set the openerTabId to the right tab. ...

Thank you, I didn't know that parameter. Let me check a better appraoch.

@pzhlkj6612
Copy link
Copy Markdown
Author

Hello!

... In Firefox at least this will automatically open the new tab after the current tab. This behaviour is actually controllable by the user using the about:config preference browser.tabs.insertRelatedAfterCurrent.

Unfortunately, Google Chrome does not have such thing:

Various browsers have different behavior for placing the new tab, some of them even allow changing it. Having an opener doesn't necessitate proximity in the tab strip. In your extension you need to specify index parameter to control the placement i.e. you can get the active tab first and add 1 to its index.

from: tabs.create always place opened tab at last even if openerTabId is set [40822765] - Chromium | https://issues.chromium.org/issues/40822765#comment2 at Feb 16, 2022 09:06PM

To make behavior consistent across browsers, I think here what we only can do is specifying the index of newly created tabs.


We can search "openerTabId" to see more discussion about it in Chromium's bug tracker: https://issues.chromium.org/issues?q=openerTabId

@pzhlkj6612 pzhlkj6612 marked this pull request as ready for review May 6, 2026 19:56
@pzhlkj6612 pzhlkj6612 requested a review from evilpie May 14, 2026 09:26
await tabs.create({ url: "/player.html", index });
};
export const openOnboardPage: () => Promise<void> = async () => {
const index = await getAdjacentTabIndex();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The onboarding page isn't really related to the current page so I don't think it really make sense to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-web Area: Web & Extensions extension Related to the Ruffle WebExtension llm The PR contains mostly LLM-generated code T-feature Type: New Feature (that Flash doesn't have)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants