fix: Find upper level heading of visible section - #4816
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
|
This PR changes the following pages (Vercel Preview Deploy links): Changed Vercel links
(Note that links will only be valid after Vercel preview deploy succeeded) |
Contributor
|
This PR probably requires the following redirects to be added to vercel.json:
|
nilubava
approved these changes
May 30, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe this PR
The current way the TOC highlighting is structured does not identify for minor headings' placement. So as the default is 2, and the value of tocDepth is always minimum 2, we need to indentify at least the second level heading containing a particular intersected section.
For example: If we are located on a section under a
h4element, the tocDepth defines that not only will it only show headings at least up to theh2level on the right, but it will not take into account any other headings, if they are intersecting. If we were to navigate to a section that is not included on the depth level of 2 or less, nothing would be highlighted on the right as the logic does not know which section that id belongs to.So on a page like
/concepts/components/prisma-client/raw-database-access#tagged-template-helpers, the visibleHeadings (before filtering based on tocDepth) and filteredVisible (after filtering) appear as such:The goal of this PR is to have a solution that finds the
visibleHeadings[0]'s (index 0 as we favor the top-most visible section) upper-level heading up to the h2 level.Changes
Update toc's visibleHeadings logic.
On the videos above you can see the difference on scrolling through a page (in this case,
/concepts/components/prisma-client/raw-database-access)What issue does this fix?
Fixes #3955
Any other relevant information
N/a