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 {
102
102
*/
103
103
@property ( { type : Boolean , attribute : 'auto-activate' } ) autoActivate = false ;
104
104
105
+ @query ( '.tabs' ) private readonly tabsScrollerElement ! : HTMLElement | null ;
105
106
@query ( 'slot' ) private readonly slotElement ! : HTMLSlotElement | null ;
106
107
107
108
private get focusedTab ( ) {
@@ -134,7 +135,11 @@ export class Tabs extends LitElement {
134
135
await this . updateComplete ;
135
136
const { tabs} = this ;
136
137
tabToScrollTo ??= this . activeTab ;
137
- if ( ! tabToScrollTo || ! tabs . includes ( tabToScrollTo ) ) {
138
+ if (
139
+ ! tabToScrollTo ||
140
+ ! tabs . includes ( tabToScrollTo ) ||
141
+ ! this . tabsScrollerElement
142
+ ) {
138
143
return ;
139
144
}
140
145
@@ -153,7 +158,7 @@ export class Tabs extends LitElement {
153
158
const to = Math . min ( min , Math . max ( max , scroll ) ) ;
154
159
// TODO(b/299934312): improve focus smoothness
155
160
const behavior : ScrollBehavior = ! this . focusedTab ? 'smooth' : 'instant' ;
156
- this . scrollTo ( { behavior, top : 0 , left : to } ) ;
161
+ this . tabsScrollerElement . scrollTo ( { behavior, top : 0 , left : to } ) ;
157
162
}
158
163
159
164
protected override render ( ) {
You can’t perform that action at this time.
0 commit comments