-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[docs site] Update TOC to scroll with page content #12730
base: main
Are you sure you want to change the base?
Conversation
2577a84
to
a35397e
Compare
a35397e
to
5700991
Compare
5700991
to
49d2c5e
Compare
<div | ||
className={classNames(styles.TOC, isNested && styles.isNested)} | ||
onPointerEnter={handlePointerEnter} | ||
onPointerLeave={handlePointerLeave} |
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.
tracking keyboard+pointer events inside the TOC to prevent the scrollLinkIntoView
running when the TOC is being scrolled independent to the Page.
Instead, if the TOC is scrolled without a selection being made, the TOC scroll will be restored to the currentHeading position on mouseout.
without mouse/focus tracking:
Screen.Recording.2024-10-02.at.15.02.27.mov
with:
Screen.Recording.2024-10-02.at.15.09.59.mov
note: after leaving the TOC container without making a selection, the page scrolls to the new mouse position. This feels a little janky. However, tracking the previous scroll location could add a lot of overhead. Is this situation worth solving for, or is TOC scroll followed by selection a more common use-case?
ℹ️ Pausing this work as their is another effort to update the documentation soon. Outstanding tasks documented below.
WHY are these changes introduced?
Fixes #147
WHAT is this pull request doing?
Updates the
TOC
component to:Other approaches considered
1. Hide the
TOC
when there is not sufficient vertical spaceRationale: we already hide the TOC below 1400px
Conclusion: The TOC height varies between pages. Hiding the TOC when there is not sufficient vertical space causes inconsistent UX between pages.
2. Break the TOC content into individual child pages
Rationale: if content is so long it requires a TOC, that is too much content.
Conclusion: Due to the different structure of pages across the top-level sections, breaking all TOC content into child pages requires additional review of the IA, and a number of changes to the site components and structure (removing descriptons; curating order of sub-pages; handling subnav; handling index pages). This time investment was deemed excessive at present, given the TOC only overflows on a handful of pages. The usage of a TOC to break content into more manageable chunks is also consistent with shopify.dev IA.
Video tophat 📹 🎩
Screen.Recording.2024-10-02.at.15.36.19.mov
How to 🎩
pnpm turbo run dev --filter=polaris.shopify.com
Content
>ActionableLanguage
):- scroll the TOC to select links below the fold
- scroll the TOC to show links below the fold, without a selection
- scroll the page to a heading associated with a link below the fold
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
🎩 checklist
README.md
with documentation changes❗ Outstanding
The work remaining for this particular PR is to fix the bug shown below - when a cursor enters the TOC, no selection is made, and the cursor leaves the TOC, the page shifts.
Suspected cause:
window
scroll
event listener is triggering when the pointer is within the TOC.Screen.Recording.2024-10-02.at.15.09.59.mov