@@ -2,6 +2,7 @@ let _emit = null
22let _containerWidth = 0
33let _dropdownOpen = false
44let _resizeObserver = null
5+ let _windowStart = 0
56
67// Each tab: 140px min-width + 20px padding + 6px gap = 166px slot
78const TAB_SLOT = 166
@@ -38,14 +39,20 @@ function Tabs(state, emit) {
3839 ? calcVisibleCount ( _containerWidth , files . length )
3940 : files . length
4041
41- // Slide window so active tab is always visible
42- let start = 0
43- let end = Math . min ( visibleCount , files . length )
44- if ( activeIndex >= end ) {
45- end = activeIndex + 1
46- start = Math . max ( 0 , end - visibleCount )
42+ // Clamp _windowStart so it never leaves trailing empty slots after resize/close
43+ _windowStart = Math . min ( _windowStart , Math . max ( 0 , files . length - visibleCount ) )
44+ _windowStart = Math . max ( 0 , _windowStart )
45+
46+ // Scroll only when active tab falls outside the current window
47+ if ( activeIndex < _windowStart ) {
48+ _windowStart = activeIndex
49+ } else if ( activeIndex >= _windowStart + visibleCount ) {
50+ _windowStart = activeIndex - visibleCount + 1
4751 }
4852
53+ const start = _windowStart
54+ const end = Math . min ( start + visibleCount , files . length )
55+
4956 const visibleFiles = files . slice ( start , end )
5057 const overflowFiles = [ ...files . slice ( 0 , start ) , ...files . slice ( end ) ]
5158 const hasOverflow = overflowFiles . length > 0
0 commit comments