Skip to content

fix(material/list): allow mat-list-item outside list#26092

Merged
crisbeto merged 1 commit intoangular:mainfrom
crisbeto:26013/list-item-optional-list
Nov 28, 2022
Merged

fix(material/list): allow mat-list-item outside list#26092
crisbeto merged 1 commit intoangular:mainfrom
crisbeto:26013/list-item-optional-list

Conversation

@crisbeto
Copy link
Member

In the MDC-based list having a MatListItem outside of a list throws a DI error, whereas in the legacy version it didn't. These changes make injecting the list optional and try to gracefully handle the absence of a list.

I've also removed the mat-mdc-list-non-interactive class since the same can be achieved without it.

Fixes #26013.

@crisbeto crisbeto added P4 A relatively minor issue that is not relevant to core functions target: patch This PR is targeted for the next patch release labels Nov 26, 2022
In the MDC-based list having a `MatListItem` outside of a list throws a DI error, whereas in the legacy version it didn't. These changes make injecting the list optional and try to gracefully handle the absence of a list.

I've also removed the `mat-mdc-list-non-interactive` class since the same can be achieved without it.

Fixes angular#26013.
@crisbeto crisbeto force-pushed the 26013/list-item-optional-list branch from 8985d12 to 0011526 Compare November 26, 2022 08:36
this._noopAnimations = animationMode === 'NoopAnimations';

if (!this._listBase._isNonInteractive) {
if (_listBase && !_listBase._isNonInteractive) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we chatted about this, but I'm still not sure if this is the best way. If the e.g. list item in a template suddenly ends up being used in e.g. an interactive list, the item will not get that treatment right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't, but I think that it'll work more or less like it does in the non-MDC version so that's why I went ahead with the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah if that's the case, then I favor this solution for the simplicity

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Nov 28, 2022
@crisbeto crisbeto self-assigned this Nov 28, 2022
@crisbeto crisbeto merged commit 936741c into angular:main Nov 28, 2022
crisbeto added a commit that referenced this pull request Nov 28, 2022
In the MDC-based list having a `MatListItem` outside of a list throws a DI error, whereas in the legacy version it didn't. These changes make injecting the list optional and try to gracefully handle the absence of a list.

I've also removed the `mat-mdc-list-non-interactive` class since the same can be achieved without it.

Fixes #26013.

(cherry picked from commit 936741c)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker P4 A relatively minor issue that is not relevant to core functions target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mat-list-item): Version 15 breaks the ability to have mat-list-item in an ngTemplate

2 participants