@@ -1271,8 +1271,14 @@ export function tryLockPosition(tabIds, reason) {
1271
1271
}
1272
1272
1273
1273
// 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
+ } ) ;
1275
1280
return ;
1281
+ }
1276
1282
1277
1283
for ( const id of tabIds ) {
1278
1284
tryLockPosition . tabIds . add ( id ) ;
@@ -1379,10 +1385,12 @@ browser.menus.onHidden.addListener((_info, _tab) => {
1379
1385
} ) ;
1380
1386
1381
1387
browser . tabs . onCreated . addListener ( _tab => {
1382
- tryFinishPositionLocking ( ) ;
1388
+ tryFinishPositionLocking ( 'on tab created' ) ;
1383
1389
} ) ;
1384
1390
1385
1391
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 } ` ) ;
1388
1396
} ) ;
0 commit comments