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

Layout moves around when switching tabs (scroll position issue) #8625

Closed
3 of 7 tasks
Tobbe opened this issue Feb 3, 2023 · 1 comment · Fixed by #8628
Closed
3 of 7 tasks

Layout moves around when switching tabs (scroll position issue) #8625

Tobbe opened this issue Feb 3, 2023 · 1 comment · Fixed by #8628
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@Tobbe
Copy link

Tobbe commented Feb 3, 2023

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Tab groups that are linked causes the page to jump when switching tabs

See this Tape that I recorded
https://s.tape.sh/bjAyxKyo

Maybe this was introduce with this change: #8486
Something about useScrollPositionBlocker() that doesn't work properly anymore.

export function useScrollPositionBlocker(): {

Reproducible demo

https://stackblitz.com/edit/github-k5xct4?file=blog/2021-08-01-mdx-blog-post.mdx

Steps to reproduce

  1. Go to the Blog in the Stackblitz preview pane to the right
  2. Scroll down to the MDX post, it has the tabs example
  3. Switch tabs and see how scroll behaves. Try both the first and the second tab group

Expected behavior

Scroll position should be maintained when switching tabs

Actual behavior

Page layout jumps

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@Tobbe Tobbe added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Feb 3, 2023
@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Feb 3, 2023
@slorber
Copy link
Collaborator

slorber commented Feb 3, 2023

Thanks for reporting, will be fixed in #8628 and included in 2.3.1 today

We restored the scroll position a bit too early before the other tabs had the opportunity to render. I fixed it by queuing the scroll restoration at the end of all the pending React re-renders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants