@@ -147,23 +147,23 @@ export class KolTreeItemWc implements TreeItemAPI {
147147 } ;
148148 }
149149
150- private getTreeParent ( ) : HTMLKolTreeWcElement | undefined {
151- return this . host ?. closest ( KolTreeTag ) as HTMLKolTreeWcElement | undefined ;
150+ private getTreeParent ( ) : ( HTMLKolTreeWcElement & { invalidateOpenItemsCache ( ) : void } ) | undefined {
151+ return this . host ?. closest ( KolTreeTag ) as ( HTMLKolTreeWcElement & { invalidateOpenItemsCache ( ) : void } ) | undefined ;
152152 }
153153
154154 /**
155155 * Focuses the link element.
156156 */
157157 @Method ( ) async focus ( ) {
158- if ( this . host ) {
159- return Promise . resolve ( this . linkElement ? .focus ( this . host ) ) ;
158+ if ( this . host && this . linkElement ) {
159+ return Promise . resolve ( this . linkElement . focus ( this . host ) ) ;
160160 }
161161 }
162162
163163 private async handleExpandClick ( event : MouseEvent ) {
164164 event . preventDefault ( ) ;
165- if ( this . host ) {
166- await this . linkElement ? .focus ( this . host ) ;
165+ if ( this . host && this . linkElement ) {
166+ await this . linkElement . focus ( this . host ) ;
167167 }
168168 await this . expand ( ) ;
169169 }
@@ -180,15 +180,14 @@ export class KolTreeItemWc implements TreeItemAPI {
180180 _open : true ,
181181 } ;
182182 // Invalidate the tree's cache of open items
183- const treeParent = this . getTreeParent ( ) ;
184- ( treeParent as any ) ?. invalidateOpenItemsCache ?.( ) ;
183+ this . getTreeParent ( ) ?. invalidateOpenItemsCache ( ) ;
185184 }
186185 }
187186
188187 private async handleCollapseClick ( event : MouseEvent ) {
189188 event . preventDefault ( ) ;
190- if ( this . host ) {
191- await this . linkElement ? .focus ( this . host ) ;
189+ if ( this . host && this . linkElement ) {
190+ await this . linkElement . focus ( this . host ) ;
192191 }
193192 await this . collapse ( ) ;
194193 }
@@ -205,8 +204,7 @@ export class KolTreeItemWc implements TreeItemAPI {
205204 _open : false ,
206205 } ;
207206 // Invalidate the tree's cache of open items
208- const treeParent = this . getTreeParent ( ) ;
209- ( treeParent as any ) ?. invalidateOpenItemsCache ?.( ) ;
207+ this . getTreeParent ( ) ?. invalidateOpenItemsCache ( ) ;
210208 }
211209 }
212210
0 commit comments