Skip to content

Commit e7c1bff

Browse files
MasterIfeanyinikk15
authored andcommitted
Bug 1977741 - Only update pinned tabs height when sidebar width changes r=nsharpley
Differential Revision: https://phabricator.services.mozilla.com/D290058
1 parent 0bb9f1e commit e7c1bff

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

browser/components/sidebar/browser-sidebar.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,10 @@ var SidebarController = {
14921492
);
14931493
this._panelResizeObserver.observe(this._box);
14941494

1495-
this._launcherDropHandler = () => (this._state.launcherDragActive = false);
1495+
this._launcherDropHandler = () => {
1496+
this._state.launcherDragActive = false;
1497+
this.updatePinnedTabsHeightOnResize();
1498+
};
14961499
this._launcherSplitter.addEventListener(
14971500
"command",
14981501
this._launcherDropHandler
@@ -1516,15 +1519,19 @@ var SidebarController = {
15161519
}
15171520
});
15181521

1519-
this._itemsWrapperResizeObserver = new ResizeObserver(async () => {
1522+
this._itemsWrapperResizeObserver = new ResizeObserver(async ([entry]) => {
15201523
await window.promiseDocumentFlushed(() => {
1521-
// Adjust pinned tabs container height if needed
15221524
requestAnimationFrame(() => {
1523-
// If we are currently moving tabs, don't resize
15241525
if (this._pinnedTabsContainer.hasAttribute("dragActive")) {
15251526
return;
15261527
}
1527-
1528+
// Only respond to WIDTH changes (sidebar being resized wider/narrower).
1529+
// Ignoring height changes prevents an infinite resize loop.
1530+
const newWidth = entry.contentBoxSize[0].inlineSize;
1531+
if (newWidth === this._pinnedTabsItemsWrapperWidth) {
1532+
return;
1533+
}
1534+
this._pinnedTabsItemsWrapperWidth = newWidth;
15281535
this.updatePinnedTabsHeightOnResize();
15291536
});
15301537
});
@@ -1579,17 +1586,32 @@ var SidebarController = {
15791586
},
15801587

15811588
updatePinnedTabsHeightOnResize() {
1589+
// Skip during sidebar width drag to prevent unpinned tabs from jumping.
1590+
// The drop handler calls this function once cleanly after drag ends.
1591+
if (this.isLauncherDragging) {
1592+
return;
1593+
}
1594+
1595+
const preferredHeight = this._state.launcherExpanded
1596+
? this._state.expandedPinnedTabsHeight
1597+
: this._state.collapsedPinnedTabsHeight;
1598+
1599+
if (!preferredHeight) {
1600+
return;
1601+
}
1602+
1603+
if (this.isLauncherDragging) {
1604+
// Clear height during drag so we can measure the natural content height accurately
1605+
this._pinnedTabsContainer.style.height = "";
1606+
}
1607+
15821608
let itemsWrapperHeight = window.windowUtils.getBoundsWithoutFlushing(
15831609
this._pinnedTabsItemsWrapper
15841610
).height;
1585-
if (this._state.pinnedTabsHeight > itemsWrapperHeight) {
1586-
this._state.pinnedTabsHeight = itemsWrapperHeight;
1587-
if (this._state.launcherExpanded) {
1588-
this._state.expandedPinnedTabsHeight = this._state.pinnedTabsHeight;
1589-
} else {
1590-
this._state.collapsedPinnedTabsHeight = this._state.pinnedTabsHeight;
1591-
}
1592-
}
1611+
1612+
// Clamp for display only — never overwrite the user's saved preference
1613+
const clampedHeight = Math.min(preferredHeight, itemsWrapperHeight);
1614+
this._pinnedTabsContainer.style.height = `${clampedHeight}px`;
15931615
},
15941616

15951617
/**

0 commit comments

Comments
 (0)