@@ -30,21 +30,22 @@ import {takeUntil} from 'rxjs/operators';
3030
3131export interface ShowHideParent {
3232 display : string ;
33+ isServer : boolean ;
3334}
3435
3536@Injectable ( { providedIn : 'root' } )
3637export class ShowHideStyleBuilder extends StyleBuilder {
3738 buildStyles ( show : string , parent : ShowHideParent ) {
3839 const shouldShow = show === 'true' ;
39- return { 'display' : shouldShow ? parent . display : 'none' } ;
40+ return { 'display' : shouldShow ? parent . display || ( parent . isServer ? 'initial' : '' ) : 'none' } ;
4041 }
4142}
4243
4344@Directive ( )
4445export class ShowHideDirective extends BaseDirective2 implements AfterViewInit , OnChanges {
4546 protected DIRECTIVE_KEY = 'show-hide' ;
4647
47- /** Original dom Elements CSS display style */
48+ /** Original DOM Element CSS display style */
4849 protected display : string = '' ;
4950 protected hasLayout = false ;
5051 protected hasFlexChild = false ;
@@ -146,8 +147,9 @@ export class ShowHideDirective extends BaseDirective2 implements AfterViewInit,
146147 if ( value === '' ) {
147148 return ;
148149 }
149- this . addStyles ( value ? 'true' : 'false' , { display : this . display } ) ;
150- if ( isPlatformServer ( this . platformId ) && this . serverModuleLoaded ) {
150+ const isServer = isPlatformServer ( this . platformId ) ;
151+ this . addStyles ( value ? 'true' : 'false' , { display : this . display , isServer} ) ;
152+ if ( isServer && this . serverModuleLoaded ) {
151153 this . nativeElement . style . setProperty ( 'display' , '' ) ;
152154 }
153155 this . marshal . triggerUpdate ( this . parentElement ! , 'layout-gap' ) ;
0 commit comments