@@ -370,7 +370,7 @@ export class TabBar<T> extends Widget {
370370 if ( value ) {
371371 this . node . classList . add ( 'lm-mod-scrollable' ) ;
372372 } else {
373- this . node . classList . add ( 'lm-mod-scrollable' ) ;
373+ this . node . classList . remove ( 'lm-mod-scrollable' ) ;
374374 }
375375 this . maybeSwitchScrollButtons ( ) ;
376376 }
@@ -708,14 +708,40 @@ export class TabBar<T> extends Widget {
708708 content [ i ] = renderer . renderTab ( { title, current, zIndex } ) ;
709709 }
710710 VirtualDOM . render ( content , this . contentNode ) ;
711+
711712 this . maybeSwitchScrollButtons ( ) ;
713+
714+ // Scroll the current tab into view.
715+ this . scrollCurrentIntoView ( ) ;
712716 }
713717
714718 protected onResize ( msg : Widget . ResizeMessage ) : void {
715719 super . onResize ( msg ) ;
716720 this . maybeSwitchScrollButtons ( ) ;
717721 }
718722
723+ /**
724+ * Scroll the current tab into view.
725+ */
726+ protected scrollCurrentIntoView ( ) {
727+ if ( this . scrollingEnabled ) {
728+ const currentNode = this . contentNode . children . item ( this . currentIndex ) ;
729+ if ( currentNode ) {
730+ currentNode . scrollIntoView ( ) ;
731+ if ( this . orientation == 'horizontal' ) {
732+ currentNode . scrollTop = 0 ;
733+ } else {
734+ currentNode . scrollLeft = 0 ;
735+ }
736+ } else {
737+ console . error ( 'Current tab node not found' ) ;
738+ }
739+ }
740+ }
741+
742+ /**
743+ * Show/hide scroll buttons if needed.
744+ */
719745 protected maybeSwitchScrollButtons ( ) {
720746 const scrollBefore = this . scrollBeforeButtonNode ;
721747 const scrollAfter = this . scrollAfterButtonNode ;
@@ -1174,6 +1200,11 @@ export class TabBar<T> extends Widget {
11741200 return ;
11751201 }
11761202
1203+ // Do nothing if neither press nor release was on a tab.
1204+ if ( index === - 1 && data . index === - 1 ) {
1205+ return ;
1206+ }
1207+
11771208 // Ignore the release if the title is not closable.
11781209 let title = this . _titles [ index ] ;
11791210 if ( ! title . closable ) {
0 commit comments