Skip to content

Commit b817d24

Browse files
author
agoloman
committed
Revert "Bug 1977741 - Only update pinned tabs height when sidebar width changes r=nsharpley" for causing bc failures @browser_vertical_tabs.js.
This reverts commit 84a8d73.
1 parent 4bbe5c2 commit b817d24

3 files changed

Lines changed: 26 additions & 50 deletions

File tree

browser/components/sidebar/browser-sidebar.js

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,10 +1511,7 @@ var SidebarController = {
15111511
);
15121512
this._panelResizeObserver.observe(this._box);
15131513

1514-
this._launcherDropHandler = () => {
1515-
this._state.launcherDragActive = false;
1516-
this.updatePinnedTabsHeightOnResize();
1517-
};
1514+
this._launcherDropHandler = () => (this._state.launcherDragActive = false);
15181515
this._launcherSplitter.addEventListener(
15191516
"command",
15201517
this._launcherDropHandler
@@ -1538,19 +1535,15 @@ var SidebarController = {
15381535
}
15391536
});
15401537

1541-
this._itemsWrapperResizeObserver = new ResizeObserver(async ([entry]) => {
1538+
this._itemsWrapperResizeObserver = new ResizeObserver(async () => {
15421539
await window.promiseDocumentFlushed(() => {
1540+
// Adjust pinned tabs container height if needed
15431541
requestAnimationFrame(() => {
1542+
// If we are currently moving tabs, don't resize
15441543
if (this._pinnedTabsContainer.hasAttribute("dragActive")) {
15451544
return;
15461545
}
1547-
// Only respond to WIDTH changes (sidebar being resized wider/narrower).
1548-
// Ignoring height changes prevents an infinite resize loop.
1549-
const newWidth = entry.contentBoxSize[0].inlineSize;
1550-
if (newWidth === this._pinnedTabsItemsWrapperWidth) {
1551-
return;
1552-
}
1553-
this._pinnedTabsItemsWrapperWidth = newWidth;
1546+
15541547
this.updatePinnedTabsHeightOnResize();
15551548
});
15561549
});
@@ -1605,32 +1598,17 @@ var SidebarController = {
16051598
},
16061599

16071600
updatePinnedTabsHeightOnResize() {
1608-
// Skip during sidebar width drag to prevent unpinned tabs from jumping.
1609-
// The drop handler calls this function once cleanly after drag ends.
1610-
if (this.isLauncherDragging) {
1611-
return;
1612-
}
1613-
1614-
const preferredHeight = this._state.launcherExpanded
1615-
? this._state.expandedPinnedTabsHeight
1616-
: this._state.collapsedPinnedTabsHeight;
1617-
1618-
if (!preferredHeight || !this._pinnedTabsContainer.childElementCount) {
1619-
return;
1620-
}
1621-
1622-
if (this.isLauncherDragging) {
1623-
// Clear height during drag so we can measure the natural content height accurately
1624-
this._pinnedTabsContainer.style.height = "";
1625-
}
1626-
16271601
let itemsWrapperHeight = window.windowUtils.getBoundsWithoutFlushing(
16281602
this._pinnedTabsItemsWrapper
16291603
).height;
1630-
1631-
// Clamp for display only — never overwrite the user's saved preference
1632-
const clampedHeight = Math.min(preferredHeight, itemsWrapperHeight);
1633-
this._pinnedTabsContainer.style.height = `${clampedHeight}px`;
1604+
if (this._state.pinnedTabsHeight > itemsWrapperHeight) {
1605+
this._state.pinnedTabsHeight = itemsWrapperHeight;
1606+
if (this._state.launcherExpanded) {
1607+
this._state.expandedPinnedTabsHeight = this._state.pinnedTabsHeight;
1608+
} else {
1609+
this._state.collapsedPinnedTabsHeight = this._state.pinnedTabsHeight;
1610+
}
1611+
}
16341612
},
16351613

16361614
/**

browser/components/sidebar/tests/browser/browser_resize_sidebar.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@ add_task(async function test_resize_of_pinned_tabs() {
233233
"Pinned tabs container was resized."
234234
);
235235

236-
for (let tab of [...gBrowser.tabs]) {
237-
if (tab.pinned) {
238-
gBrowser.unpinTab(tab);
239-
}
240-
}
241236
while (gBrowser.tabs.length > 1) {
242237
BrowserTestUtils.removeTab(gBrowser.tabs.at(-1));
243238
}

browser/components/sidebar/tests/browser/browser_vertical_tabs.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,26 @@ add_task(async function test_toggle_vertical_tabs() {
214214
true
215215
);
216216
let hidden2 = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden");
217-
const tabToPin = gBrowser.selectedTab;
218-
await openAndWaitForContextMenu(contextMenu, tabToPin, async () => {
219-
info("Tab context menu opened");
220-
let pinTabOption = document.getElementById("context_pinTab");
221-
if (!pinTabOption) {
222-
info("Pin tab context menu option not found");
217+
await openAndWaitForContextMenu(
218+
contextMenu,
219+
gBrowser.selectedTab,
220+
async () => {
221+
info("Tab context menu opened");
222+
let pinTabOption = document.getElementById("context_pinTab");
223+
if (!pinTabOption) {
224+
info("Pin tab context menu option not found");
225+
}
226+
pinTabOption?.click();
223227
}
224-
pinTabOption?.click();
225-
});
228+
);
226229

227230
await promiseTabPinned;
228-
// Wait for the specific pinned tab to appear in the container
231+
// Wait for pinned tab to render
229232
let pinnedTabsContainer = document.getElementById("pinned-tabs-container");
230233
await BrowserTestUtils.waitForMutationCondition(
231234
pinnedTabsContainer,
232235
{ childList: true },
233-
() => pinnedTabsContainer.contains(tabToPin)
236+
() => pinnedTabsContainer.childElementCount === 1
234237
);
235238
info("Tab pinned via the context menu");
236239
contextMenu.hidePopup();

0 commit comments

Comments
 (0)