Skip to content
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

fix(router): Delay router scroll event until navigated components hav… #47563

Closed
wants to merge 2 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Sep 27, 2022

…e rendered

Currently, the scroll event is fired immediately after the NavigationEnd. However, this is problematic because a change detection has not been able to run, meaning that Angular will not yet have run the update block of the component templates being rendered as part of the navigation.

This change delays the scroll event using a setTimeout, which will allow Angular's change detection to run before the scroll restoration is performed.

fixes #24547

@atscott atscott added area: router target: patch This PR is targeted for the next patch release labels Sep 27, 2022
@ngbot ngbot bot modified the milestone: Backlog Sep 27, 2022
@atscott
Copy link
Contributor Author

atscott commented Sep 27, 2022

TGP

@atscott atscott force-pushed the scrollerdelay branch 2 times, most recently from 7d9321e to 6e7cd35 Compare September 27, 2022 21:18
@atscott atscott added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Sep 29, 2022
@atscott
Copy link
Contributor Author

atscott commented Sep 29, 2022

Reviewer note: While I don't consider this a breaking change, I had to adjust some of our own test assertions. For safety, let's merge this into a major version only. If there are many reports of this truly being breaking, we can later add a note to the breaking changes page on aio.

…e rendered

Currently, the scroll event is fired immediately after the
`NavigationEnd`. However, this is problematic because a change detection
has not been able to run, meaning that Angular will not yet have run the update
block of the component templates being rendered as part of the navigation.

This change delays the scroll event using a `setTimeout`, which will
allow Angular's change detection to run before the scroll restoration is
performed.

fixes angular#24547
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@atscott LGTM 👍

packages/router/src/router_scroller.ts Show resolved Hide resolved
@atscott atscott force-pushed the scrollerdelay branch 4 times, most recently from a3b17a1 to bf257d5 Compare October 17, 2022 18:28
@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Oct 17, 2022
@dylhunn dylhunn added target: rc This PR is targeted for the next release-candidate and removed target: major This PR is targeted for the next major release labels Oct 19, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Oct 19, 2022

This PR was merged into the repository by commit af8afee.

@dylhunn dylhunn closed this in af8afee Oct 19, 2022
dylhunn pushed a commit that referenced this pull request Oct 19, 2022
…e rendered (#47563)

Currently, the scroll event is fired immediately after the
`NavigationEnd`. However, this is problematic because a change detection
has not been able to run, meaning that Angular will not yet have run the update
block of the component templates being rendered as part of the navigation.

This change delays the scroll event using a `setTimeout`, which will
allow Angular's change detection to run before the scroll restoration is
performed.

fixes #24547

PR Close #47563
nouraellm pushed a commit to nouraellm/angular that referenced this pull request Nov 6, 2022
…e rendered (angular#47563)

Currently, the scroll event is fired immediately after the
`NavigationEnd`. However, this is problematic because a change detection
has not been able to run, meaning that Angular will not yet have run the update
block of the component templates being rendered as part of the navigation.

This change delays the scroll event using a `setTimeout`, which will
allow Angular's change detection to run before the scroll restoration is
performed.

fixes angular#24547

PR Close angular#47563
@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 Nov 19, 2022
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
…e rendered (angular#47563)

Currently, the scroll event is fired immediately after the
`NavigationEnd`. However, this is problematic because a change detection
has not been able to run, meaning that Angular will not yet have run the update
block of the component templates being rendered as part of the navigation.

This change delays the scroll event using a `setTimeout`, which will
allow Angular's change detection to run before the scroll restoration is
performed.

fixes angular#24547

PR Close angular#47563
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 area: router target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scrollPositionRestoration has several problems
3 participants