[DO NOT MERGE]: POC: DocNavbarItems link across instances to the correct version #1345
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.
What is the purpose of the change
This is a POC PR, demonstrating how we could fix #1333.
I say "could" because there is risk associated with this fix -- we're overriding multiple internal functions for this component, which is unsafe in the sense that docusaurus has no obligation to let us know when these things change/break. A future minor/patch version update of docusaurus could leave us with broken code, and/or we will likely spend time in the future rewriting our overrides based on the updated internals.
I also don't know if we've determined how much of a problem #1333 really is - it certainly annoys me, but it might be an edge case that no one but me runs into.
Video demonstrating the problem, the source code responsible for it, and the fix: https://www.loom.com/share/ea910112df7643b4856ed60c93105157
What's going wrong?
When browsing a document within Optimize, Docusaurus is trying to identify which version you want to see for the top nav links, but it's basing it on where you were within the main docs, instead of where you currently are.
How does this fix it?
This PR swizzles the DocNavbarItem component, so that we can write our own version of
useLayoutDoc, so that we can write our own version ofuseDocsVersionCandidates.More detailed comments are in the code.
Are there related marketing activities
No
When should this change go live?
🤷 should it go live?
PR Checklist
/versioned_docsdirectory, or they are not for an already released version./docsdirectory, or they are not for future versions.