Skip to content

Commit

Permalink
fix(stepper): fix change detection issue when number of step content …
Browse files Browse the repository at this point in the history
…children changed (#989)
  • Loading branch information
emoralesb05 authored Nov 22, 2017
1 parent 45797ed commit c9d24d6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/platform/core/steps/step-body/step-body.component.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<ng-content></ng-content>
<div class="td-step-body">
<div class="td-step-content-wrapper"
[@tdCollapse]="!active">
<div #contentRef cdkScrollable [class.td-step-content]="contentRef.children.length || contentRef.textContent.trim()">
[@tdCollapse]="!active">
<div #contentRef cdkScrollable [class.td-step-content]="hasContent">
<ng-content select="[td-step-body-content]"></ng-content>
</div>
<div #actionsRef [class.td-step-actions]="actionsRef.children.length || actionsRef.textContent.trim()">
<div #actionsRef
[class.td-step-actions]="hasActions">
<ng-content select="[td-step-body-actions]"></ng-content>
</div>
</div>
<div #summaryRef [@tdCollapse]="active || !isComplete()"
[class.td-step-summary]="summaryRef.children.length || summaryRef.textContent.trim()">
<div #summaryRef
[@tdCollapse]="active || !isComplete()"
[class.td-step-summary]="hasSummary">
<ng-content select="[td-step-body-summary]"></ng-content>
</div>
</div>
23 changes: 22 additions & 1 deletion src/platform/core/steps/step-body/step-body.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, Input, ViewChild, ElementRef } from '@angular/core';

import { StepState } from '../step.component';

Expand All @@ -14,6 +14,27 @@ import { TdCollapseAnimation } from '../../common/common.module';
})
export class TdStepBodyComponent {

@ViewChild('contentRef', { read: ElementRef }) contentRef: ElementRef;

get hasContent(): boolean {
return this.contentRef &&
(this.contentRef.nativeElement.children.length > 0 || !!this.contentRef.nativeElement.textContent.trim());
}

@ViewChild('actionsRef', { read: ElementRef }) actionsRef: ElementRef;

get hasActions(): boolean {
return this.actionsRef &&
(this.actionsRef.nativeElement.children.length > 0 || !!this.actionsRef.nativeElement.textContent.trim());
}

@ViewChild('summaryRef', { read: ElementRef }) summaryRef: ElementRef;

get hasSummary(): boolean {
return this.summaryRef &&
(this.summaryRef.nativeElement.children.length > 0 || !!this.summaryRef.nativeElement.textContent.trim());
}

/**
* active?: boolean
* Sets for active/inactive states on body.
Expand Down

0 comments on commit c9d24d6

Please sign in to comment.