fix(v2): adjust correct behavior of navbar when active anchor #2248
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.
Motivation
In PR #2162 I missed up one use case: when a user opens a web page with an anchor (hash). At the moment, in this case the navbar is always hidden, even if the page scrolls to the top.
To demonstrate this bug see GIF (target path - docs/introduction/#️-disclaimer):
The previous implementation with
document.activeElement
was wrong, because in fact we have no way via JS to determine the active (focused) anchor. (In CSS, this is possible through the pseudo-class:target
). Therefore, in order to achieve the desired result, it was required to track the change in the hash location and then synchronize the changes in the hash URL (when switching (updating) the route).As a result, there was more code, but the behavior of hideable navbar is what it should be.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
#
sign in heading) or clicks on the link in TOC.