@@ -370,7 +370,7 @@ export class TabBar<T> extends Widget {
370
370
if ( value ) {
371
371
this . node . classList . add ( 'lm-mod-scrollable' ) ;
372
372
} else {
373
- this . node . classList . add ( 'lm-mod-scrollable' ) ;
373
+ this . node . classList . remove ( 'lm-mod-scrollable' ) ;
374
374
}
375
375
this . maybeSwitchScrollButtons ( ) ;
376
376
}
@@ -708,14 +708,41 @@ export class TabBar<T> extends Widget {
708
708
content [ i ] = renderer . renderTab ( { title, current, zIndex } ) ;
709
709
}
710
710
VirtualDOM . render ( content , this . contentNode ) ;
711
+
711
712
this . maybeSwitchScrollButtons ( ) ;
713
+
714
+ // Scroll the current tab into view.
715
+ this . scrollCurrentIntoView ( ) ;
712
716
}
713
717
714
718
protected onResize ( msg : Widget . ResizeMessage ) : void {
715
719
super . onResize ( msg ) ;
716
720
this . maybeSwitchScrollButtons ( ) ;
717
721
}
718
722
723
+ /**
724
+ * Scroll the current tab into view.
725
+ */
726
+ protected scrollCurrentIntoView ( ) {
727
+ if ( this . scrollingEnabled ) {
728
+ const contentNode = this . contentNode ;
729
+ const currentNode = contentNode . children . item ( this . currentIndex ) ;
730
+ if ( currentNode ) {
731
+ currentNode . scrollIntoView ( ) ;
732
+ if ( this . orientation == 'horizontal' ) {
733
+ contentNode . scrollTop = 0 ;
734
+ } else {
735
+ contentNode . scrollLeft = 0 ;
736
+ }
737
+ } else {
738
+ console . error ( 'Current tab node not found' ) ;
739
+ }
740
+ }
741
+ }
742
+
743
+ /**
744
+ * Show/hide scroll buttons if needed.
745
+ */
719
746
protected maybeSwitchScrollButtons ( ) {
720
747
const scrollBefore = this . scrollBeforeButtonNode ;
721
748
const scrollAfter = this . scrollAfterButtonNode ;
@@ -1174,6 +1201,11 @@ export class TabBar<T> extends Widget {
1174
1201
return ;
1175
1202
}
1176
1203
1204
+ // Do nothing if neither press nor release was on a tab.
1205
+ if ( index === - 1 && data . index === - 1 ) {
1206
+ return ;
1207
+ }
1208
+
1177
1209
// Ignore the release if the title is not closable.
1178
1210
let title = this . _titles [ index ] ;
1179
1211
if ( ! title . closable ) {
0 commit comments