angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.32k stars 6.73k forks source link

bug(MatList): content projected mat-list-items do not apply mat-mdc-list-item-interactive #27608

Open Cowraider opened 1 year ago

Cowraider commented 1 year ago

Is this a regression?

The previous version in which this bug was not present was

14.2.6

Description

After updating to Angular v15 projecting mat-list-items into the mat-nav-list does no longer work as expected. The hover effect is not working as the class mat-mdc-list-item-interactive is not added.

<mat-nav-list>
  <ng-container *ngTemplateOutlet="items"></ng-container>
</mat-nav-list>

<ng-template #items>
  <a mat-list-item href="https://google.com"> google </a>
  <a mat-list-item href="https://angular.io"> angular </a>
</ng-template>

Reproduction

StackBlitz link: https://stackblitz.com/edit/ng5v1w-bbsdvs?file=src%2Fexample%2Flist-overview-example.html Steps to reproduce:

  1. hover over not working items

Expected Behavior

Content projected items should behave like they were added "directly".

Actual Behavior

Mat-list-items do not get the mat-mdc-list-item-interactive class and therefore displayed as non-interactive.

Environment

ProjectBay commented 11 months ago

My workaround for now is to add class="mat-mdc-list-item-interactive" matRipple

to the mat-list-item element manually

krishnanmk commented 10 months ago

+1

ActJV commented 8 months ago

Same behavior in v15 with mat-action-list and templated items <button mat-list-item>. Workaround atm is indeed to add the mat-mdc-list-item-interactive class and matRipple.

Any other workaround to look trough the templating?