Have you read the Contributing Guidelines on issues?
Prerequisites
Description
Here's a proposed fix for: When linking to an anchor-ref in a docusaurus document, an apparent race condition may cause the in-page scroll to fail. This appears to be an old issue (#8351 for example and is an acknowledged problem in dev -- also mentioned in the CLI documentation). Even though this issue mostly affects dev environments, fixing it would be a boon for developers...and the race condition that causes it can make it a problem with "slow-loading" apps.
The fix is fairly straightforward: here's a link to my code
The same code is copied in the sandbox linked below, as well, but is commented out in the config for the demo (see below). FWIW, the code has been picked apart by code rabbit to cover all sorts of edge cases, see my related Companion PR for details and diagnostics (you'll have to expand resolved issues to see descriptions of the edge cases)...
I think the fix would go here more permanently if you agree with the need?? I'd be happy to give it a shot with your support.
Reproducible demo
https://codesandbox.io/p/devbox/silly-andras-68yl3g?file=%2Fdocusaurus.config.js%3A156%2C5-156%2C18
Steps to reproduce
- Go to the demo link
- Try the three different anchor-nav links. Only the second one will take you to the anchor ("Generate a new site"; the other two go to the top of the page)
- If you uncomment the
clientModules line near the end of docusaurus.config.js (make sure it recompiles) and try again everything works.
Expected behavior
all three links should go to "Generate a new site" in the intro page.
Actual behavior
see above
Your environment
- Public source code: code sandbox and GitHub linked above
- Public site URL: see above
- Docusaurus version used: "3.9.2"
- Environment name and version (e.g. Chrome 89, Node.js 16.4): latest chrome, sandbox
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): code sandbox
Self-service
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.Description
Here's a proposed fix for: When linking to an anchor-ref in a docusaurus document, an apparent race condition may cause the in-page scroll to fail. This appears to be an old issue (#8351 for example and is an acknowledged problem in dev -- also mentioned in the CLI documentation). Even though this issue mostly affects dev environments, fixing it would be a boon for developers...and the race condition that causes it can make it a problem with "slow-loading" apps.
The fix is fairly straightforward: here's a link to my code
The same code is copied in the sandbox linked below, as well, but is commented out in the config for the demo (see below). FWIW, the code has been picked apart by code rabbit to cover all sorts of edge cases, see my related Companion PR for details and diagnostics (you'll have to expand resolved issues to see descriptions of the edge cases)...
I think the fix would go here more permanently if you agree with the need?? I'd be happy to give it a shot with your support.
Reproducible demo
https://codesandbox.io/p/devbox/silly-andras-68yl3g?file=%2Fdocusaurus.config.js%3A156%2C5-156%2C18
Steps to reproduce
clientModulesline near the end of docusaurus.config.js (make sure it recompiles) and try again everything works.Expected behavior
all three links should go to "Generate a new site" in the intro page.
Actual behavior
see above
Your environment
Self-service