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

core(fr): preserve scroll position in gatherers #14660

Merged
merged 6 commits into from
Jan 13, 2023
Merged

Conversation

adamraine
Copy link
Member

This functionality was never brought from legacy navs into FR so we should be consistent. Also, preserving the scroll position will at least be less destructive during flows (#14336).

Additionally, we don't need to restore the scroll position after every gatherer, only tap targets and a11y. I've noticed some issues when we try to restore the scroll position immediately after the bfcache gatherer in legacy mode.

Moving the scroll position restoration inside the tap targets and a11y gatherers achieves both of these goals.

@adamraine adamraine requested a review from a team as a code owner January 10, 2023 22:55
@adamraine adamraine requested review from connorjclark and removed request for a team January 10, 2023 22:55
@paulirish
Copy link
Member

Additionally, we don't need to restore the scroll position after every gatherer, only tap targets and a11y

nice, yeah i like that.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

The only problem with this approach currently is that if the gatherer code errors, the position won't be restored. Previously it would have been. Certainly there are times when we've seen Axe throw an error, so we should account for this.

@brendankenny
Copy link
Member

FWIW that was added in #8625 so gatherers didn't have to worry about previous gatherers cleaning up after themselves and we wouldn't have to worry about remembering to make gatherers clean up after themselves.

At first glance restoring scroll position after a gatherer seems like a pretty lightweight cleanup step. If the issue is that any evaluateAsync() after the bfcache gatherer runs will throw, that seems like it's going to come up soon or later regardless and it's worth looking into. I see the session error in the logs, I assume because of the navigation. Why don't timespans with (cross-origin?) navigations run into the same problem?

@adamraine
Copy link
Member Author

FWIW that was added in #8625 so gatherers didn't have to worry about previous gatherers cleaning up after themselves and we wouldn't have to worry about remembering to make gatherers clean up after themselves.

Personally I think it's a good exercise to have gatherers clean up after themselves, especially if we're trying to be mindful of how a gatherer affects page state during a flow. #8625 was before my time and I only found out about it because I was investigating the evaluateAsync errors.

At first glance restoring scroll position after a gatherer seems like a pretty lightweight cleanup step. If the issue is that any evaluateAsync() after the bfcache gatherer runs will throw, that seems like it's going to come up soon or later regardless and it's worth looking into. I see the session error in the logs, I assume because of the navigation. Why don't timespans with (cross-origin?) navigations run into the same problem?

This is a good question. My best guess is that we run into errors when evaluateAsync is called immediately after a navigation. The errors seem to pup up when we call Page.getResourceTree. This might be worth opening a separate issue for.

@adamraine adamraine merged commit 4d950df into main Jan 13, 2023
@adamraine adamraine deleted the fr-scroll-position branch January 13, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants