material-components-web icon indicating copy to clipboard operation
material-components-web copied to clipboard

[mdc-tab] Button inside tab label is not clickable

Open jiayuandeng opened this issue 2 years ago • 1 comments

A button inside tab label is not clickable, no matter the tab is disabled or not.

For example, a tab group like this:

<mat-tab-group>
  <mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab">
    Contents for {{tab}} tab
  </mat-tab>
  <mat-tab disabled>
    <ng-template mat-tab-label>
      <button mat-icon-button (click)="addTab()">
        <mat-icon>add_circle</mat-icon>
      </button>
    </ng-template>
  </mat-tab>
</mat-tab-group>

The icon button is visible, but clicking the button never triggers addTab().

It works in non-mdc mat-tab: https://stackblitz.com/edit/angular-1iudkz?file=src%2Fapp%2Ftab-group-dynamic-example.html

jiayuandeng avatar Sep 16 '22 06:09 jiayuandeng

try adding this to your style.css file

.mdc-tab__content{ pointer-events: all!important; }

afif-bouzid avatar Nov 24 '22 07:11 afif-bouzid