@@ -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,40 @@ 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 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
+ */
719
745
protected maybeSwitchScrollButtons ( ) {
720
746
const scrollBefore = this . scrollBeforeButtonNode ;
721
747
const scrollAfter = this . scrollAfterButtonNode ;
@@ -1174,6 +1200,11 @@ export class TabBar<T> extends Widget {
1174
1200
return ;
1175
1201
}
1176
1202
1203
+ // Do nothing if neither press nor release was on a tab.
1204
+ if ( index === - 1 && data . index === - 1 ) {
1205
+ return ;
1206
+ }
1207
+
1177
1208
// Ignore the release if the title is not closable.
1178
1209
let title = this . _titles [ index ] ;
1179
1210
if ( ! title . closable ) {
0 commit comments