Skip to content

fix(overlay): injection errors for scroll strategy providers in lazy-loaded modules #11213

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

Merged

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented May 7, 2018

Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scroll strategy. The error comes from the fact that the scroll strategies were being provided at the root, whereas the Overlay provider was provided normally, causing it to be missing when a module is lazy-loaded.

Fixes #10820.

@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround pr: needs review labels May 7, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 7, 2018
@crisbeto
Copy link
Member Author

crisbeto commented May 7, 2018

Marking as a P2 since it's a regression.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed pr: needs review labels May 7, 2018
@crisbeto crisbeto force-pushed the 10820/overlay-scroll-strategy-providers branch 3 times, most recently from 997b921 to a6c6eae Compare May 8, 2018 21:01
@cyrilletuzi
Copy link
Contributor

@crisbeto Is there a specific reason you choose to revert back other services to classic providers, instead of going the other way by providing Overlay with providedIn: 'root' like other services?

I'm asking because it would lighten me up a lot about new tree-shakable providers (doc is saying to use them everywhere, but Angular core and Material are still using classic providers for their main services, so I'm confused about what should be done and I do a library where it's important).

@crisbeto
Copy link
Member Author

crisbeto commented May 9, 2018

@cyrilletuzi The Overlay provider uses the ComponentFactoryResolver to resolve components. We want it to be scoped to the current module injector, rather than the root.

provide: MAT_TOOLTIP_SCROLL_STRATEGY,
deps: [Overlay],
useFactory: MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this object literal provider is also not working. We should just change all of them at this point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should also mention that it's possibly an issue w/ Closure Compiler being too aggressive.

@crisbeto crisbeto force-pushed the 10820/overlay-scroll-strategy-providers branch from a6c6eae to ebabfe3 Compare May 11, 2018 07:16
@crisbeto
Copy link
Member Author

I've moved all the object literal providers into variables @jelbourn.

@tinayuangao
Copy link
Contributor

@crisbeto Please fix the lint test

@crisbeto
Copy link
Member Author

Good to go @tinayuangao.

@crisbeto crisbeto force-pushed the 10820/overlay-scroll-strategy-providers branch from ebabfe3 to bafc7eb Compare May 15, 2018 17:30
@tinayuangao
Copy link
Contributor

@crisbeto Please rebase. Thanks!

…loaded modules

Fixes injection errors being thrown by the overlay-based providers that have injection tokens for the default scroll strategy. The error comes from the fact that the scroll strategies were being provided at the root, whereas the `Overlay` provider was provided normally, causing it to be missing when a module is lazy-loaded.

Fixes angular#10820.
@crisbeto crisbeto force-pushed the 10820/overlay-scroll-strategy-providers branch from bafc7eb to c61a1cc Compare May 16, 2018 05:42
@crisbeto
Copy link
Member Author

Rebased.

@tinayuangao tinayuangao merged commit 0cda47c into angular:master May 16, 2018
@tinayuangao tinayuangao added the target: minor This PR is targeted for the next minor release label May 16, 2018
@tinayuangao tinayuangao removed the target: patch This PR is targeted for the next patch release label May 16, 2018
@tinayuangao
Copy link
Contributor

Changed to target:minor since the autocomplete-origin.ts is added in #11284. That PR is marked as minor.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No provider for Overlay! StaticInjectorError(AppModule)[MatMenuTrigger -> Overlay]:
5 participants