-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
fix(v2): reinit hideable header position when page switched #2160
Conversation
Deploy preview for docusaurus-2 ready! Built with commit eae3456 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have to fall back to a non-React way of event handling, then I think it's better to not use the plugin API instead. You can access the current route through a more React-ish approach (Router.Context
?) I believe.
@yangshun I do not quite understand how to do this via context, could you help me? |
I need to look into the code to tell you exactly how to do so. React Router stores the current routing state in context and I think we should be able to access it. Otherwise, maybe try out @endiliey would know better. |
i can only say that client side routing is pretty limited in this scope and isnt perfect |
As a proof-of-concept, I used the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is much cleaner but I'm not sure if we want to expose react-router-dom
like this. We make people import router through @docusaurus/router
. Not opposed to this though since I don't think we'll move away from React Router. Thoughts @endiliey?
Motivation
Auto-hide header has an unpleasant bug at the moment: when clicking to a new page, header position is not recalculated - header remains hidden, although it should be displayed (see test plan). I tried to fix it via a custom event, I'm not sure how much is correct, so maybe there is a better solution.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan