Page MenuHomePhabricator

ToC: micro-interactions
Closed, DeclinedPublic

Description

Description

A few details related to the ToC that we've decided to address as part of the visual design phase of the project.

1. Bolding the active section link can cause unexpected line-wrapping (✅ fixed)

Fixed via @Jdrewniak's brilliance in: T314670: [Visual refinements] Bold active section in ToC
Because the bolded text is slightly wider than the non-bolded text, in some cases this causes line-wrapping

2. Clicking a ToC section link without scrolling the page initially cases the ToC to "jump"

This will be helped a little bit by: T314330: [Visual refinements] Stop TOC from jumping when sticky header appears (logged-in only)
Because the sticky position of the ToC is closer to the top of the screen than the initial position of the ToC, if you click a ToC section link without scrolling the page (such that the ToC would reach its sticky position) the ToC "jumps" to its sticky position. One way to fix this would be to adjust the sticky height of the ToC, however doing that would result in a significant amount of vertical dead space above the ToC.

current behaviorpossible solution
first click toc jump.gif (326×600 px, 241 KB)
first click no toc jump.gif (326×600 px, 234 KB)

(if GIFs above aren't auto-playing, click to view)

3. What should be the threshold for considering a section "active"?

The ToC bolds/highlights the "active" section link, i.e. the link corresponding to the section of the page you are currently viewing. However since sections can be short you can often have multiple sections on the screen at once. We can't know where on the screen you are looking, and therefore which section you're actually reading, so we have to guess. The current logic considers a section active when the section heading crosses a threshold ~70px from the top of the screen (which accounts for the sticky header). We can easily adjust this threshold to be lower down on the page if we would like. This screen recording demonstrates various section headings (highlighted with a pink background) crossing that threshold:

(note, to easily add the pink backgrounds use: document.getElementById( 'bodyContent' ).querySelectorAll( 'h1, h2, h3, h4, h5, h6' ).forEach( node => node.style.backgroundColor = 'pink');)

4. Should we avoid auto-scrolling the ToC in cases where you click on a section link that's towards the bottom of the ToC

e.g. in this situation the ToC would not auto-scroll (until the person then scrolled a little bit):

Event Timeline

  1. Clicking a ToC section link without scrolling the page initially cases the ToC to "jump"

I chatted a bit with @bwang about this one. This is kinda how sticky positioning works in browsers, so I'm not sure what we could do here.

The others seem relatively straightforward to fix.

ovasileva lowered the priority of this task from High to Medium.Mar 29 2022, 4:52 PM
ovasileva moved this task from Incoming to Current Fiscal Year on the Web-Team-Backlog board.

It would be better if the active session of TOC get auto expanded, so that its sub session will be more easier and quicker to reach.

Removing inactive assignee. (Please update such things as part of offboarding - thanks.)

The proposals in this ticket are based off of an older TOC design and might not be relevant anymore. I'm declining this ticket based on that context. Regarding the suggestions:

1. Bolding the active section link can cause unexpected line-wrapping - (✅ fixed)
2. Clicking a ToC section link without scrolling the page initially cases the ToC to "jump" - This is a side-effect of browser behaviour, not really fixable.
3. What should be the threshold for considering a section "active"? - this can still be confusing for small sections, but it has the benefit of accomodating the floating TOC button at small resolutions, (so that the heading doesn't overlap the button).
4. Should we avoid auto-scrolling the ToC in cases where you click on a section link that's towards the bottom of the ToC? - I think overriding auto-scrolling in this situation would introduce a lot of complexity in the code for relatively little gain in UX. I know that's a judgement call, but given the Web team is shifting priorities away from Vector 2022 as our main focus, I don't see the benefit of adding this functionality at this point.