@@ -365,13 +365,28 @@ define(function (require, exports, module) {
365365 /** @type {jQueryObject } Overflow dropdown button */
366366 let _$overflowBtn = null ;
367367
368+ let _checkTabOverflowTimer = null ;
369+
368370 function _checkTabOverflow ( ) {
371+ // Coalesce multiple calls (e.g. rapid tab adds) and defer to the
372+ // next frame so that measurements happen after layout settles.
373+ if ( _checkTabOverflowTimer ) {
374+ cancelAnimationFrame ( _checkTabOverflowTimer ) ;
375+ }
376+ _checkTabOverflowTimer = requestAnimationFrame ( _doCheckTabOverflow ) ;
377+ }
378+
379+ function _doCheckTabOverflow ( ) {
380+ _checkTabOverflowTimer = null ;
369381 if ( ! _$tabBar ) {
370382 return ;
371383 }
372- // Remove collapsed state first to measure true width
384+
385+ // Remove collapsed state first to measure true width.
386+ // Use a 1px tolerance to avoid sub-pixel rounding flicker at
387+ // boundary sizes (e.g. scrollWidth 678 vs clientWidth 677).
373388 _$tabBar . removeClass ( "bottom-panel-tabs-collapsed" ) ;
374- const isOverflowing = _$tabsOverflow [ 0 ] . scrollWidth > _$tabsOverflow [ 0 ] . clientWidth ;
389+ const isOverflowing = _$tabsOverflow [ 0 ] . scrollWidth > _$tabsOverflow [ 0 ] . clientWidth + 1 ;
375390 _$tabBar . toggleClass ( "bottom-panel-tabs-collapsed" , isOverflowing ) ;
376391
377392 // Check if still overflowing after collapse
@@ -854,9 +869,9 @@ define(function (require, exports, module) {
854869 } ) ;
855870
856871 // Observe the outer tab bar container so that only external resizes
857- // (e.g. window resize) trigger a re-check. Observing _$tabsOverflow
858- // would cause an infinite loop in WebKit because _checkTabOverflow
859- // toggles classes that change _$tabsOverflow's size.
872+ // (e.g. window resize, plugin panel open/close ) trigger a re-check.
873+ // Observing _$tabsOverflow would cause an infinite loop in WebKit
874+ // because _checkTabOverflow toggles classes that change its size.
860875 new ResizeObserver ( _checkTabOverflow ) . observe ( _$tabBar [ 0 ] ) ;
861876
862877 // Restore maximize state from preferences (survives reload).
0 commit comments