Closed Bug 1922268 Opened 11 months ago Closed 10 months ago

Clicking "New tab to right" in a context menu inadvertently adds a tab to a group, if the next tab to the right is in a group

Categories

(Firefox :: Tabbed Browser, defect, P2)

defect
Points:
2

Tracking

()

VERIFIED FIXED
134 Branch
Tracking Status
firefox134 --- verified

People

(Reporter: jswinarton, Assigned: sthompson)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fidefe-tabgrps-tabbrowser] [UX-tabgrps-review])

Attachments

(2 files)

No description provided.
Blocks: 1907099
Status: NEW → RESOLVED
Closed: 11 months ago
Duplicate of bug: 1921830
Resolution: --- → DUPLICATE

This may not be a strict dupe. "Add Tab to Right" seems to use gBrowser.addAdjacentNewTab which ultimately uses gBrowser.addTab and gBrowser._insertTabAtIndex to insert a tab based on a tab index value.

https://bugzilla.mozilla.org/show_bug.cgi?id=1921830 uses gBrower.moveTabTo based on a tab index value.

Both moveTabTo and _insertTabAtIndex have their own logic for calculating how to place a tab in the DOM based on context.

With the tab browser in the state

A
B
Group
  C
  D

B has index 1 and C has index 2. Right-clicking B and clicking Add Tab to Right calls gBrowser.addAdjacentNewTab with tab B.

addAdjacentNewTab calls addTrustedTab with index 2 (B's tab._tPos == 1, the code calls addTrustedTab with tab._tPos + 1)

addTrustedTab forwards directly to addTab.

addTab calls _insertTabAtIndex with index 2 and empty values for ownerTab and openerTab.

_insertTabAtIndex grabs the tabAfter as this.tabs[index], so that picks tab C with index 2. Then it calls this.tabContainer.insertBefore(tab, tabAfter). Since tab C is nested under the tab group in the DOM, the insertBefore makes the new tab a sibling of C and therefore makes it contained within the tab group.

A
B
Group
  E
  C
  D

I think we'd want something more like

  • if the tabAfter is in a group and there is no ownerTab nor openerTab, then we should do this.tabContainer.insertBefore(tab, tabAfter.group) to insert the new tab as a standalone tab before the tab group
  • if the tabAfter is in a group and there is an ownerTab or openerTab, then
    • if the ownerTab/openerTab group is different from the tabAfter.group, we should assume the tab should be inserted into the ownerTab/openerTab group. Not really sure how we get to this case. It might be sufficient to insert as the last tab in the owner/opener's tab group, e.g. this.tabContainer.appendChild(ownerTab.group, tab)
    • if the ownerTab/openerTab group is the same as the tabAfter.group, this.tabContainer.insertBefore(tab, tabAfter); should work fine
  • if there is no tabAfter, it's inserting to the end of the tab bar
    • if there is no ownerTab/openerTab, the new tab should stand alone, so this.tabContainer.insertBefore(tab, tabAfter); will work fine
    • if there is an ownerTab/openerTab
      • if ownerTab/openerTab has a group, presumably we're inserting the tab to the end of the group, so we'd do this.tabContainer.appendChild(ownerTab.group, tab)
      • if ownerTab/openerTab doesn't have a group, I think this.tabContainer.insertBefore(tab, tabAfter); still works fine

Ok, that makes sense. I'll reopen this. Thank you for the comprehensive write-up, this is very clear!

Status: RESOLVED → REOPENED
No longer duplicate of bug: 1921830
Resolution: DUPLICATE → ---
Duplicate of this bug: 1923678
Type: defect → task
Blocks: 1908417
Severity: -- → S3
Type: task → defect
Points: --- → 1
Priority: -- → P2
Assignee: nobody → sthompson
Summary: Clicking "add tab to right" in a context menu inadvertently adds a tab to a group, if the next tab to the right is in a group → Clicking "New tab to right" in a context menu inadvertently adds a tab to a group, if the next tab to the right is in a group
Points: 1 → 2
Whiteboard: [fidefe-tabgrps-tabbrowser] [UX-tabgrps-review]

Fixes a number of edge cases where tabs created/inserted in the tab strip were incorrectly being placed inside of an adjacent tab group or incorrectly being placed outside of the intended tab group

Pushed by sthompson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/818b70032c34 inserting tabs behaves with adjacent tab groups r=dao,tabbrowser-reviewers
Status: REOPENED → RESOLVED
Closed: 11 months ago10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Flags: qe-verify+

On Win10x64 using Firefox 135.0a1 and 134.0b3 I installed 'Simple Tab Groups' add-on and If I open a new tab to the right after a group tab this opens a new tab in the group. Is this expected? Thank you.
A
tab group B
new tab C in group B

Flags: needinfo?(jswinarton)

This bug affects Firefox's built-in tab group feature, which is still under development. This feature does not require any add-on.

In 134 and 135, you need to enable the browser.tabs.groups.enabled preference in about:config.

If you right-click on a tab inside of a tab group, then choosing "New Tab to Right" should open the new tab inside of the tab group. If you right-click on a standalone tab, then choosing "New Tab to Right" should open the new tab as a standalone tab.

Flags: needinfo?(jswinarton)

I was able to reproduce the issue on Win10x64 using Firefox 134.0a1(20241028212656) after enabling the pref. Thank you.
Verified as fixed on Win10x64/Ubuntu 24.04 using Firefox builds 134.0b5(20241204091850) and 135.0a1(20241205213207).

Duplicate of this bug: 1937479
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: