I am trying to override the default collapse and expand functionality for the Angular Material Expansion Panel.
https://material.angular.io/components/expansion/overview
By default the Expansion Panel will toggle expanding/collapsing if the mouse is clicked ANYWHERE in the Panel Header.
I'd like to suppress this functionality so I can add custom "toolbar" buttons to the header.
I've tried adding a click event handler to Panel Header and the calling: event.stopPropogation();
to try to prevent the expanding and collapsing to no avail.
I've also tried adding a button with a click event handler to the Panel Header to see if I could sidestep the expanding and collapsing. Unfortunatley, this did not work either.
https://stackblitz.com/edit/angular-ritpbb
HTML
<mat-expansion-panel #matExpansionPanel
[class.active]="selected"
(click)="componentSelected($event)"
[expanded]="expanded">
<mat-expansion-panel-header (click)="togglePanel($event)">
Collapse Test <button mat-button>select panel</button>
</mat-expansion-panel-header>
CONTENT FOR EXPANSION PANEL
<mat-action-row>
<button mat-button (click)="buttonClick($event)">remove</button>
</mat-action-row>
</mat-expansion-panel>
.TS
import { Component } from '@angular/core';
import { MatExpansionPanel } from '@angular/material';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
expanded = true;
selected = false;
componentSelected($event) {
this.selected = !this.selected;
event.stopPropagation();
}
buttonClick($event) {
this.selected = !this.selected;
console.log('test');
event.stopPropagation();
}
togglePanel($event) {
this.expanded = !this.expanded;
//event.stopPropagation();
}
}