fix: Fixed zen-empty-tab movement while inserting items into a group (#9948)

This commit is contained in:
octaviusz
2025-08-21 11:45:51 +03:00
committed by GitHub
parent 21e82c2379
commit c1e2c7ec36
2 changed files with 24 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f411960db1 100644 index d80a66a01002e78a9c65545d08fe786328ddf124..749991884735a1a6d7b1a2c2e1c77f7eae2e5c28 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js --- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -422,15 +422,60 @@ @@ -422,15 +422,60 @@
@@ -673,7 +673,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
moveBefore = false; moveBefore = false;
} else if (!element.pinned && targetElement && targetElement.pinned) { } else if (!element.pinned && targetElement && targetElement.pinned) {
// If the caller asks to move an unpinned element next to a pinned // If the caller asks to move an unpinned element next to a pinned
@@ -6165,14 +6303,29 @@ @@ -6165,14 +6303,34 @@
// move the tab group right before the first unpinned tab. // move the tab group right before the first unpinned tab.
// 4. Moving a tab group and the first unpinned tab is grouped: // 4. Moving a tab group and the first unpinned tab is grouped:
// move the tab group right before the first unpinned tab's tab group. // move the tab group right before the first unpinned tab's tab group.
@@ -692,11 +692,16 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
+ if (targetElement?.group?.hasAttribute("split-view-group")) { + if (targetElement?.group?.hasAttribute("split-view-group")) {
+ targetElement = targetElement.group; + targetElement = targetElement.group;
+ } + }
+ // When the folder is the last element in the pinned section, + if (targetElement?.hasAttribute("zen-empty-tab")) {
+ // targetElement is a tab with the zen-empty-tab attribute. + // When the folder is the last element in the pinned section,
+ // If the movement is from top to bottom, it must be redefined as a folder. + // targetElement is a tab with the zen-empty-tab attribute.
+ if (targetElement?.hasAttribute("zen-empty-tab") && !moveBefore) { + // If the movement is from top to bottom, it must be redefined as a folder.
+ targetElement = targetElement.group; + if (!moveBefore) {
+ targetElement = targetElement.group;
+ } else {
+ // Always insert an element after zen-empty-tab to avoid it moving from the first position
+ moveBefore = false;
+ }
+ } + }
let getContainer = () => let getContainer = () =>
@@ -704,7 +709,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
element.pinned element.pinned
? this.tabContainer.pinnedTabsContainer ? this.tabContainer.pinnedTabsContainer
: this.tabContainer; : this.tabContainer;
@@ -6181,7 +6334,7 @@ @@ -6181,7 +6339,7 @@
element, element,
() => { () => {
if (moveBefore) { if (moveBefore) {
@@ -713,7 +718,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
} else if (targetElement) { } else if (targetElement) {
targetElement.after(element); targetElement.after(element);
} else { } else {
@@ -6230,7 +6383,7 @@ @@ -6230,7 +6388,7 @@
if (!this.isTab(aTab)) { if (!this.isTab(aTab)) {
throw new Error("Can only move a tab into a tab group"); throw new Error("Can only move a tab into a tab group");
} }
@@ -722,7 +727,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
return; return;
} }
if (aTab.group && aTab.group.id === aGroup.id) { if (aTab.group && aTab.group.id === aGroup.id) {
@@ -6324,6 +6477,10 @@ @@ -6324,6 +6482,10 @@
moveActionCallback(); moveActionCallback();
@@ -733,7 +738,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
// Clear tabs cache after moving nodes because the order of tabs may have // Clear tabs cache after moving nodes because the order of tabs may have
// changed. // changed.
this.tabContainer._invalidateCachedTabs(); this.tabContainer._invalidateCachedTabs();
@@ -7221,7 +7378,7 @@ @@ -7221,7 +7383,7 @@
// preventDefault(). It will still raise the window if appropriate. // preventDefault(). It will still raise the window if appropriate.
break; break;
} }
@@ -742,7 +747,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
window.focus(); window.focus();
aEvent.preventDefault(); aEvent.preventDefault();
break; break;
@@ -8166,6 +8323,7 @@ @@ -8166,6 +8328,7 @@
aWebProgress.isTopLevel aWebProgress.isTopLevel
) { ) {
this.mTab.setAttribute("busy", "true"); this.mTab.setAttribute("busy", "true");
@@ -750,7 +755,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
gBrowser._tabAttrModified(this.mTab, ["busy"]); gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected; this.mTab._notselectedsinceload = !this.mTab.selected;
} }
@@ -9157,7 +9315,7 @@ var TabContextMenu = { @@ -9157,7 +9320,7 @@ var TabContextMenu = {
); );
contextUnpinSelectedTabs.hidden = contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !this.multiselected; !this.contextTab.pinned || !this.multiselected;
@@ -759,7 +764,7 @@ index d80a66a01002e78a9c65545d08fe786328ddf124..50f4d52090139256b00c7183fe61e6f4
// Build Ask Chat items // Build Ask Chat items
TabContextMenu.GenAI.buildTabMenu( TabContextMenu.GenAI.buildTabMenu(
document.getElementById("context_askChat"), document.getElementById("context_askChat"),
@@ -9476,6 +9634,7 @@ var TabContextMenu = { @@ -9476,6 +9639,7 @@ var TabContextMenu = {
) )
); );
} else { } else {

View File

@@ -1346,18 +1346,20 @@
switch (stateData?.prevSiblingInfo?.type) { switch (stateData?.prevSiblingInfo?.type) {
case 'group': { case 'group': {
const folder = document.getElementById(stateData.prevSiblingInfo.id); const folder = document.getElementById(stateData.prevSiblingInfo.id);
gBrowser.moveTabAfter(node, folder); folder.after(node);
break; break;
} }
case 'tab': { case 'tab': {
const tab = parentWorkingData.node.querySelector( const tab = parentWorkingData.node.querySelector(
`[zen-pin-id="${stateData.prevSiblingInfo.id}"]` `[zen-pin-id="${stateData.prevSiblingInfo.id}"]`
); );
gBrowser.moveTabAfter(node, tab); tab.after(node);
break; break;
} }
default: { default: {
const start = parentWorkingData.node.querySelector('.zen-tab-group-start'); // Should insert after zen-empty-tab
const start =
parentWorkingData.node.querySelector('.zen-tab-group-start').nextElementSibling;
start.after(node); start.after(node);
} }
} }