fix(nuxt): scroll to top on page navigation when scroll-behavior: smo⦠#25817
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.
π Linked issue
fixes #25816
fixes #19239
β Type of change
π Description
In Firefox, if you have
scroll-behavior: smooth
style set onhtml
, navigation between pages doesn't scroll to top (reproduction). The root cause of the problem is that awaitingnextTick
in router.options.ts doesn't work in that case. It's not clear to me why since the nextTick implementation doesn't seem to be doing anything too strange. That said, replacingawait nextTick
with awaiting asetTimeout
fixes things. This happens to be related to something being addressed in a currently open PR where both myself and @bernhardberger found that asetTimeout
was necessary.I'll admit I'm not particularly familiar with why
nextTick
is specifically being called here, but as far as I can tell replacing it the way I did fully resolves #25816.In addition, I fixed a slight missed edge case, if you click on the same link 20 times in a row that all link to the same page, the next time you click on another link, the 20
hookOnce
s that you created are all resolved at the same time returning undefined. It doesn't seem to cause any issues, but there's no reason to enter line 45+ if we're not going to scroll anyways when you click the same link.π Checklist