Skip to content

[18.1] AfterNextRender only invokes first phase callback when provided multiple via new API #56979

Closed

Description

@atsjo

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

core

Is this a regression?

No

Description

The new AfterRender/AfterNextRender API in v18.1 allows providing callbacks for different phases in a single call. This works fine for AfterRender, but doesn't for AfterNextRender.

Repro by creating minimal app via 18.1 cli and add:

    afterRender({ earlyRead: () => console.log('each render earlyRead'), write: () => console.log('each render write') });
    afterNextRender({ earlyRead: () => console.log('next render earlyRead'), write: () => console.log('next render write') });

in component constructor, and view logging in devtools... ('next render write' is missing)

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

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

Angular CLI: 18.1.0
Node: 22.4.1
Package Manager: pnpm 9.5.0
OS: win32 x64

Angular: 18.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, material
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0 (cli-only)
@angular-devkit/build-angular   18.1.0
@angular-devkit/core            18.1.0
@angular-devkit/schematics      18.1.0
@angular/fire                   18.0.1
@schematics/angular             18.1.0
ng-packagr                      18.1.0
rxjs                            7.8.1
typescript                      5.5.3
zone.js                         0.14.7

Anything else?

also using nx

Activity

  1. JoostK commented on Jul 14, 2024

    @JoostK
    Member

    Ah, indeed, the destruction logic is incorrect. The first callback that executes destroys all other phases for which a callback had been registered.

    /cc @mmalerba

  2. added
    area: core
    on Jul 14, 2024
  3. added this to the needsTriage milestone on Jul 14, 2024
  4. self-assigned this
    on Jul 15, 2024
  5. added a commit that references this issue on Jul 15, 2024
    175f040
  6. added a commit that references this issue on Jul 16, 2024
    5682527
  7. added a commit that references this issue on Jul 16, 2024
    e504ad9
  8. atsjo commented on Jul 17, 2024

    @atsjo
    Author

    the fix only worked half way... multiple phases now gets called, but if try to pass a parameter from one phase to the next, it doesn't work with AfterNextRender, the parameter is always undefined (but again it works with AfterRender!)

  9. JeanMeche commented on Jul 17, 2024

    @JeanMeche
    Member

    @atsjo You're right, 2nd PR is up #57031

  10. angular-automatic-lock-bot commented on Aug 17, 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.

  11. locked and limited conversation to collaborators on Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: corestate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions