@@ -20,6 +20,7 @@ import {
2020import { ENTER , SPACE } from '@koobiq/cdk/keycodes' ;
2121import { Subject } from 'rxjs' ;
2222import { KBQ_TITLE_TEXT_REF , KbqTitleTextRef } from '../title' ;
23+ import { isFunction } from '../utils' ;
2324import { KbqOptgroup } from './optgroup' ;
2425
2526/**
@@ -237,7 +238,7 @@ export class KbqOption extends KbqOptionBase implements AfterViewChecked, OnDest
237238 private mostRecentViewValue = '' ;
238239
239240 constructor (
240- private readonly element : ElementRef < HTMLElement > ,
241+ private readonly elementRef : ElementRef < HTMLElement > ,
241242 private readonly changeDetectorRef : ChangeDetectorRef ,
242243 @Optional ( ) @Inject ( KBQ_OPTION_PARENT_COMPONENT ) private readonly parent : KbqOptionParentComponent ,
243244 @Optional ( ) readonly group : KbqOptgroup
@@ -265,10 +266,14 @@ export class KbqOption extends KbqOptionBase implements AfterViewChecked, OnDest
265266 this . stateChanges . complete ( ) ;
266267 }
267268
269+ /** @docs -private */
268270 getHeight ( ) : number {
269- const DOMRect : DOMRect = this . element . nativeElement . getClientRects ( ) [ 0 ] ;
271+ const element = this . elementRef . nativeElement ;
270272
271- return DOMRect ? DOMRect . height : 0 ;
273+ // For SSR compatibility
274+ if ( ! isFunction ( element . getClientRects ) ) return 0 ;
275+
276+ return element . getClientRects ( ) [ 0 ] ?. height ?? 0 ;
272277 }
273278
274279 select ( emitEvent : boolean = true ) : void {
@@ -357,7 +362,7 @@ export class KbqOption extends KbqOptionBase implements AfterViewChecked, OnDest
357362 }
358363
359364 getHostElement ( ) : HTMLElement {
360- return this . element . nativeElement ;
365+ return this . elementRef . nativeElement ;
361366 }
362367}
363368
0 commit comments