@@ -140,8 +140,8 @@ export class MdlExpansionPanelComponent implements AfterContentInit {
140
140
this . _toggle ( true ) ;
141
141
}
142
142
143
- collapse ( ) {
144
- this . _toggle ( false ) ;
143
+ collapse ( emitOnChange ?: boolean ) {
144
+ this . _toggle ( false , emitOnChange ) ;
145
145
}
146
146
147
147
disableToggle ( ) {
@@ -152,11 +152,11 @@ export class MdlExpansionPanelComponent implements AfterContentInit {
152
152
this . disabled = false ;
153
153
}
154
154
155
- private _toggle ( isExpanded : boolean ) {
155
+ private _toggle ( isExpanded : boolean , emitOnChange : boolean = true ) {
156
156
this . isExpanded = isExpanded ;
157
157
this . content . isExpanded = `${ isExpanded } ` ;
158
158
this . header . isExpanded = isExpanded ;
159
- this . onChange . emit ( isExpanded ) ;
159
+ if ( emitOnChange ) this . onChange . emit ( isExpanded ) ;
160
160
}
161
161
}
162
162
@@ -169,6 +169,7 @@ export class MdlExpansionPanelComponent implements AfterContentInit {
169
169
} )
170
170
export class MdlExpansionPanelGroupComponent implements AfterContentInit {
171
171
@ContentChildren ( MdlExpansionPanelComponent ) panels : QueryList < MdlExpansionPanelComponent > ;
172
+ @Output ( 'mdl-panel-active-changed' ) selectedPanelEmitter = new EventEmitter ( ) ;
172
173
expandedIndex : number = - 1 ;
173
174
174
175
ngAfterContentInit ( ) {
@@ -199,13 +200,14 @@ export class MdlExpansionPanelGroupComponent implements AfterContentInit {
199
200
panel . onChange . subscribe ( ( isExpanded : boolean ) => {
200
201
if ( isExpanded ) {
201
202
if ( i !== this . expandedIndex && this . expandedIndex >= 0 ) {
202
- this . panels . toArray ( ) [ this . expandedIndex ] . collapse ( ) ;
203
+ this . panels . toArray ( ) [ this . expandedIndex ] . collapse ( false ) ;
203
204
}
204
205
this . expandedIndex = i ;
205
206
}
206
207
if ( ! isExpanded && i === this . expandedIndex ) {
207
208
this . expandedIndex = - 1 ;
208
209
}
210
+ this . selectedPanelEmitter . emit ( { index : this . expandedIndex } ) ;
209
211
} ) ;
210
212
} ) ;
211
213
}
0 commit comments