Skip to content

Commit ed3dc7a

Browse files
committed
Don't finish scroll lock when multiple tabs are closed
1 parent 442b775 commit ed3dc7a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

webextensions/sidebar/scroll.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,14 @@ export function tryLockPosition(tabIds, reason) {
12711271
}
12721272

12731273
// Lock scroll position only when the closing affects to the max scroll position.
1274-
if (mNormalScrollBox.scrollTop < mNormalScrollBox.scrollTopMax - Size.getTabHeight())
1274+
if (mNormalScrollBox.scrollTop < mNormalScrollBox.scrollTopMax - Size.getTabHeight() - mNormalScrollBox.querySelector(`.${Constants.kTABBAR_SPACER}`).getBoundingClientRect().height) {
1275+
log('tryLockPosition: scroll position is not affected ', tabIds, {
1276+
scrollTop: mNormalScrollBox.scrollTop,
1277+
scrollTopMax: mNormalScrollBox.scrollTopMax,
1278+
height: Size.getTabHeight(),
1279+
});
12751280
return;
1281+
}
12761282

12771283
for (const id of tabIds) {
12781284
tryLockPosition.tabIds.add(id);
@@ -1379,10 +1385,12 @@ browser.menus.onHidden.addListener((_info, _tab) => {
13791385
});
13801386

13811387
browser.tabs.onCreated.addListener(_tab => {
1382-
tryFinishPositionLocking();
1388+
tryFinishPositionLocking('on tab created');
13831389
});
13841390

13851391
browser.tabs.onRemoved.addListener(tabId => {
1386-
if (!tryLockPosition.tabIds.has(tabId))
1387-
tryFinishPositionLocking();
1392+
if (tryLockPosition.tabIds.has(tabId) ||
1393+
Tab.get(tabId)?.$TST.collapsed)
1394+
return;
1395+
tryFinishPositionLocking(`on tab removed ${tabId}`);
13881396
});

0 commit comments

Comments
 (0)