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

fix(v2): reinit hideable header position when page switched #2160

Merged
merged 3 commits into from
Jan 3, 2020

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Dec 29, 2019

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

Before After
screencast-nimbus-capture-2019 12 29-22_37_23 screencast-nimbus-capture-2019 12 29-22_39_21

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 29, 2019
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Dec 29, 2019

Deploy preview for docusaurus-2 ready!

Built with commit eae3456

https://deploy-preview-2160--docusaurus-2.netlify.com

Copy link
Contributor

@yangshun yangshun left a 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.

@lex111
Copy link
Contributor Author

lex111 commented Dec 30, 2019

@yangshun I do not quite understand how to do this via context, could you help me?

@yangshun
Copy link
Contributor

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 useLocation() and you can respond to the location changes - https://reacttraining.com/react-router/web/api/Hooks/uselocation

@endiliey would know better.

@endiliey
Copy link
Contributor

i can only say that client side routing is pretty limited in this scope and isnt perfect

@lex111
Copy link
Contributor Author

lex111 commented Dec 30, 2019

As a proof-of-concept, I used the useLocation hook instead of the plugin API - it works fine! But it needs to be moved somewhere else deeper?

Copy link
Contributor

@yangshun yangshun left a 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?

@yangshun yangshun merged commit de57ab1 into facebook:master Jan 3, 2020
@yangshun yangshun added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Jan 12, 2020
@yangshun yangshun deleted the fix-auto-hide-header-pos branch June 21, 2020 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants