Skip to content

EVENT_MANAGER_PLUGINS injection order #37850

Closed

Description

@waterplea

🐞 bug report

Affected Package

The issue is caused by package @angular/platform-browser

Is this a regression?

No

Description

If I provide my own EventManagerPlugins with multi token EVENT_MANAGER_PLUGINS in a module of my library, order of modules matters - if BrowserModule appears after my module in upmost App module then DomEventsPlugin is injected after my plugins and events never reach my plugins, see this line here:

https://github.com/angular/angular/blob/10.0.1/packages/platform-browser/src/dom/events/dom_events.ts#L20

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-event-plugins-bug

🔥 Exception or Error

No exceptions, plugins just never work

🌍 Your Environment

Angular Version:

Probably every version

Anything else relevant?

Activity

  1. added
    area: core
    on Jun 30, 2020
  2. added this to the needsTriage milestone on Jun 30, 2020
  3. JiaLiPassion commented on Jul 3, 2020

    @JiaLiPassion
    Contributor

    I believe this is by design, the multi token inject order does matter, but I think we need to add document about this, it seems there is no EVENT_MANAGER_PLUGINS doc now, I will try to add it.

  4. waterplea commented on Jul 3, 2020

    @waterplea
    ContributorAuthor

    I know it matters, but here, really, all that matters is DomEventsPlugin MUST be the last one. I believe it's best to enforce it with something more reliable than reversing the array. Even Angular's own code with 3 built-in plugins implicitly dependant on this which is not very safe situation in a long run.

  5. JiaLiPassion commented on Jul 4, 2020

    @JiaLiPassion
    Contributor

    I see your point, but in my opinion, DomEventsPlugin is just a normal plugin, I don't think Angular should treat it specially. Otherwise, it breaks the current mechanism of the multi injector. So maybe some doc + linter rule will be a solution for this?

  6. waterplea commented on Jul 4, 2020

    @waterplea
    ContributorAuthor

    This is reasonable. But then the problem is in DomEventsPlugin, because it is written as a special case, not as a normal plugin.

  7. added
    P4
    on Oct 28, 2020
  8. modified the milestones: needsTriage, Backlog on Oct 28, 2020
  9. 16 remaining items

  10. angular-automatic-lock-bot commented on Mar 20, 2026

    @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 Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area: corecore: event listeners

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions