fix(dynamic overlay): prevent multiple onStable subscriptions #2494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please read and mark the following check list before creating a pull request:
Short description of what this resolves:
The main fix is 419ca7c. After the change, dynamic overlay unsubscribes from
zone.onStable
once overlay got destroyed. Before, every time theshow
method was called, we were creating an additional subscription, which leads to multipleupdatePosition
calls.Changes from 3379373 is an additional fix, which ensures dynamic overlay context and config properties updating only once some property actually changed. Before, because of we were passing a new object to
overlayConfig
andcontext
methods overlay was recreated on everyngOnChanges
run. See commit description for details. UPD: 1763905 is a refactor of the way overlay config objects updated. First I decided to use change object fromOnChanges
hook, but we have tests which check if direct manipulation of component instance properties (not in the template) is also picked up.OnChanges
hook doesn't track such changes, so I moved overlay config objects update code to the setters. This way you can change properties from anywhere (from template or component instance properties) and it'll work anyway.The third commit 1840a9d, has an additional small fix. We need to call
updatePosition
once overlay content change, as it could affect overlay dimensions. It worked fine before because of the bug fixed in this PR.