File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export class Tabs extends LitElement {
102102 */
103103 @property ( { type : Boolean , attribute : 'auto-activate' } ) autoActivate = false ;
104104
105+ @query ( '.tabs' ) private readonly tabsScrollerElement ! : HTMLElement | null ;
105106 @query ( 'slot' ) private readonly slotElement ! : HTMLSlotElement | null ;
106107
107108 private get focusedTab ( ) {
@@ -134,7 +135,11 @@ export class Tabs extends LitElement {
134135 await this . updateComplete ;
135136 const { tabs} = this ;
136137 tabToScrollTo ??= this . activeTab ;
137- if ( ! tabToScrollTo || ! tabs . includes ( tabToScrollTo ) ) {
138+ if (
139+ ! tabToScrollTo ||
140+ ! tabs . includes ( tabToScrollTo ) ||
141+ ! this . tabsScrollerElement
142+ ) {
138143 return ;
139144 }
140145
@@ -153,7 +158,7 @@ export class Tabs extends LitElement {
153158 const to = Math . min ( min , Math . max ( max , scroll ) ) ;
154159 // TODO(b/299934312): improve focus smoothness
155160 const behavior : ScrollBehavior = ! this . focusedTab ? 'smooth' : 'instant' ;
156- this . scrollTo ( { behavior, top : 0 , left : to } ) ;
161+ this . tabsScrollerElement . scrollTo ( { behavior, top : 0 , left : to } ) ;
157162 }
158163
159164 protected override render ( ) {
You can’t perform that action at this time.
0 commit comments