Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting NG0956 when presenting mat-calendar in a cdkConnectedOverlay #29008

Closed
jpike88 opened this issue May 7, 2024 · 1 comment · Fixed by #29028
Closed

Getting NG0956 when presenting mat-calendar in a cdkConnectedOverlay #29008

jpike88 opened this issue May 7, 2024 · 1 comment · Fixed by #29028
Assignees
Labels
area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@jpike88
Copy link

jpike88 commented May 7, 2024

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

I have a button presenting an overlay with a mat-calendar in it, and I get the above warning each time I present it. I can't reach into mat-calendar to fix this issue, but the warning is super annoying and I want to get rid of it.

NG0956: The configured tracking expression (track by identity) caused re-creation of the entire collection of size 7. This is an expensive operation requiring destruction and subsequent creation of DOM nodes, directives, components etc. Please review the "track expression" and make sure that it uniquely identifies items in a collection. Find more at https://angular.io/errors/NG0956

I don't know what is 'collection 7' either, that tells me little about the location of the problematic template code. But the mat-calendar is definitely the problem here as it goes away if I remove it.

Template code looks like below.

<button
				(click)="
					$event.stopImmediatePropagation();
					isOpen ? closePopover() : openPopover()
				"
				cdkOverlayOrigin
				#trigger="cdkOverlayOrigin"
			>
				<mat-icon>today</mat-icon>
			</button>
			<ng-template
				cdkConnectedOverlay
				[cdkConnectedOverlayOrigin]="trigger"
				[cdkConnectedOverlayOpen]="isOpen"
				(overlayOutsideClick)="closePopover()"
			>
<mat-calendar
						>
						</mat-calendar>
			</ng-template>

Please provide a link to a minimal reproduction of the bug

cannot reproduce on stackblitz, just see the code I have

Please provide the exception or error you saw

`NG0956: The configured tracking expression (track by identity) caused re-creation of the entire collection of size 7. This is an expensive operation requiring destruction and subsequent creation of DOM nodes, directives, components etc. Please review the "track expression" and make sure that it uniquely identifies items in a collection. Find more at https://angular.io/errors/NG0956`

Please provide the environment you discovered this bug in (run ng version)

Angular @next as of the time of posting this issue

Anything else?

No response

@JeanMeche JeanMeche transferred this issue from angular/angular May 7, 2024
@JeanMeche
Copy link
Member

Note, this is an warning introduced in v18. The link printed in the console will be fixed when angular/angular#55554 lands.

@crisbeto crisbeto self-assigned this May 9, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/datepicker labels May 9, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue May 9, 2024
Fixes that the calendar was triggering some newly-introduced warnings from the framework.

Fixes angular#29008.
crisbeto added a commit to crisbeto/material2 that referenced this issue May 9, 2024
Fixes that the calendar was triggering some newly-introduced warnings from the framework.

Fixes angular#29008.
crisbeto added a commit that referenced this issue May 9, 2024
Fixes that the calendar was triggering some newly-introduced warnings from the framework.

Fixes #29008.

(cherry picked from commit 9a502e7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/datepicker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants