Skip to content

QueryList not sorted according to the actual state #42519

@DRYmag

Description

@DRYmag

Bug Report

Affected Package

This issue is caused by package @angular/core.

Is this a regression?

Not my case.

Description

I display a list of components via * ngFor and query them with ViewChildren.
The list can be reordered (from the data), visually it's ok, the QueryList triggers changes (it's ok too), but the list in the QueryList is not sorted, is the same as at the beginning.

I found the cause, each component is encapsulated in an ng-template in the * ngFor. If I make my components direct children of the * ngFor, it works.

I made a minimal reproduction with a sorted list 1, 2, 3, 4, I reorganized 3, 4, 1, 2 but in the QueryList it is still 1, 2, 3, 4 .

Minimal Reproduction

https://ng-run.com/edit/B0RMoh8QgGE9Syf3GBSf?open=app%2Fapp.component.ts&layout=1

Exception or Error

None.

Your Environment

Angular Version:


Angular CLI: 11.2.13
Node: 14.15.4
OS: win32 x64

Angular: 11.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.13
@angular-devkit/build-angular   0.1102.13
@angular-devkit/core            11.2.13
@angular-devkit/schematics      11.2.13
@angular/cdk                    11.2.13
@angular/cli                    11.2.13
@angular/flex-layout            11.0.0-beta.33
@schematics/angular             11.2.13
@schematics/update              0.1102.13
rxjs                            6.6.3
typescript                      4.0.3

Anything else relevant?
Nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimecore: queries

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions