Skip to content

Elements removed from DOM using @for and SSR #53163

Closed

Description

@divvjson

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

Don't known / other

Is this a regression?

No

Description

Elements are removed from the DOM when they are reordered using the Material DragDropModule.

It seems like this issue only occurs when using the new @for syntax in conjunction with SSR enabled.

So, if I use *ngFor or disable SSR this issue does not occur.

The reordering example is the same as on the official docs: https://material.angular.io/cdk/drag-drop/overview#reordering-lists

There's no error in the console.

drag-drop-bug.mp4

Please provide a link to a minimal reproduction of the bug

DragDropBug

Please provide the exception or error you saw

No response

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

Angular CLI: 17.0.3
Node: 20.9.0
Package Manager: npm 10.1.0
OS: win32 x64

Angular: 17.0.4
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.3
@angular-devkit/build-angular   17.0.3
@angular-devkit/core            17.0.3
@angular-devkit/schematics      17.0.3
@angular/cdk                    17.0.1
@angular/cli                    17.0.3
@angular/material               17.0.1
@angular/ssr                    17.0.3
@schematics/angular             17.0.3
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

No response

Activity

  1. JeanMeche commented on Nov 25, 2023

    @JeanMeche
    Member

    HI !
    Could you share a repro on a github repo ?
    I did reuse the same example on a ng new --ssr project and couldn't reproduce that issue.

    Angular CLI: 17.0.3
    Node: 20.10.0
    Package Manager: npm 10.2.3
    OS: darwin x64
    
    Angular: 17.0.4
    ... animations, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, platform-server
    ... router
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1700.3
    @angular-devkit/build-angular   17.0.3
    @angular-devkit/core            17.0.3
    @angular-devkit/schematics      17.0.3
    @angular/cli                    17.0.3
    @angular/material               17.0.1
    @angular/ssr                    17.0.3
    @schematics/angular             17.0.3
    rxjs                            7.8.1
    typescript                      5.2.2
    zone.js                         0.14.2
    
  2. added
    needs reproduction
    on Nov 25, 2023
  3. divvjson commented on Nov 26, 2023

    @divvjson
    Author
  4. added
    core: control flow
    and removed
    needs reproduction
    on Nov 26, 2023
  5. added
    area: core
    on Nov 27, 2023
  6. modified the milestone: needsTriage on Nov 27, 2023
  7. JeanMeche commented on Nov 27, 2023

    @JeanMeche
    Member

    Quick investigation on my side :

    When the reconciliation calls attach() in swap(), shouldAddViewToDom() return false but the hydrated element doesn't exist anymore as it has been deleted before.

  8. AndrewKushnir commented on Nov 28, 2023

    @AndrewKushnir
    Contributor

    @JeanMeche thanks for the investigation! Could you please try creating a repro without Material components, so that we can use this scenario in tests and perform further investigation? Thank you.

  9. added a commit that references this issue on Nov 28, 2023
  10. JeanMeche commented on Nov 28, 2023

    @JeanMeche
    Member
  11. 3 remaining items

  12. added
    P2
    on Nov 30, 2023
  13. modified the milestones: needsTriage, Backlog on Nov 30, 2023
  14. added a commit that references this issue on Dec 1, 2023
    bcac1e4
  15. added a commit that references this issue on Dec 1, 2023
    8e366e8
  16. angular-automatic-lock-bot commented on Jan 1, 2024

    @angular-automatic-lock-bot

    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.

  17. locked and limited conversation to collaborators on Jan 1, 2024
  18. added a commit that references this issue on Jan 23, 2024
    fa9bd6f
  19. added a commit that references this issue on Jan 26, 2024
    40fefdc
  20. added a commit that references this issue on Jan 26, 2024
    0189139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2area: corecore: control flowcore: hydrationstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions