From 39fdda89585131dd691be7de02eb34770351533d Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Fri, 7 Mar 2025 13:59:23 +0100 Subject: [PATCH] Added support to unsplit tabs when dragging them to the sidebar --- .../base/zen-components/ZenViewSplitter.mjs | 33 +++++++++++++++++-- .../tabbrowser/content/tabs-js.patch | 11 ++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/browser/base/zen-components/ZenViewSplitter.mjs b/src/browser/base/zen-components/ZenViewSplitter.mjs index fac04a298..97d76ffb7 100644 --- a/src/browser/base/zen-components/ZenViewSplitter.mjs +++ b/src/browser/base/zen-components/ZenViewSplitter.mjs @@ -1588,7 +1588,9 @@ class ZenViewSplitter extends ZenDOMOperatedFeature { this.splitTabs([draggedTab, droppedOnTab], gridType, 1); } } - this._maybeRemoveFakeBrowser(false); + window.requestAnimationFrame(() => { + this._maybeRemoveFakeBrowser(false); + }); if (browserContainer) { gZenUIManager.motion @@ -1606,12 +1608,39 @@ class ZenViewSplitter extends ZenDOMOperatedFeature { } ) .then(() => { - gBrowser.tabbox.removeAttribute('style'); + this._maybeRemoveFakeBrowser(false); }); } return true; } + handleTabDrop(event, urls, replace, inBackground) { + if (!inBackground || replace || urls.length !== 1) { + return false; + } + const url = urls[0]; + if (!url.startsWith('panel-')) { + return false; + } + const browserContainer = document.getElementById(url); + const browser = browserContainer?.querySelector('browser'); + if (!browser) { + return false; + } + const tab = gBrowser.getTabForBrowser(browser); + if (!tab) { + return false; + } + if (tab.splitView) { + // Unsplit the tab and exit from the drag view + this.dropZone?.removeAttribute('enabled'); + this.disableTabRearrangeView(event); + this.removeTabFromSplit(browserContainer); + return true; + } + return false; + } + /** * Gets or creates a tab group for split view tabs * @param {Array} tabs Initial tabs to add to the group if creating new diff --git a/src/browser/components/tabbrowser/content/tabs-js.patch b/src/browser/components/tabbrowser/content/tabs-js.patch index 09123e634..4c3e69d98 100644 --- a/src/browser/components/tabbrowser/content/tabs-js.patch +++ b/src/browser/components/tabbrowser/content/tabs-js.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js -index fa96568d366fd3608f9bd583fa793150bd815c8b..9151fa411faa9689c7b079fafe0fab1234177f40 100644 +index fa96568d366fd3608f9bd583fa793150bd815c8b..a2a0ca3982634252abfdad20e768431a840ea19b 100644 --- a/browser/components/tabbrowser/content/tabs.js +++ b/browser/components/tabbrowser/content/tabs.js @@ -94,7 +94,7 @@ @@ -97,6 +97,15 @@ index fa96568d366fd3608f9bd583fa793150bd815c8b..9151fa411faa9689c7b079fafe0fab12 postTransitionCleanup(); } else { let onTransitionEnd = transitionendEvent => { +@@ -1249,7 +1263,7 @@ + return; + } + } +- ++ if (gZenViewSplitter.handleTabDrop(event, urls, replace, inBackground)) return; + gBrowser.loadTabs(urls, { + inBackground, + replace, @@ -1279,13 +1293,23 @@ return; }