fix: Second ToC element not collapsible or highlight-able #1505
+7
−7
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.
Here's a quick and dirty fix to ToC to make sure when multiple ToCs are added to the DOM (either visibly or not when say
Component.DesktopOnly()
is used), the rest of the ToC elements can be collapsed or title-highlighted.ToC is useful for navigating long blog posts, but because it's typically to the right, it'd get pushed down to the bottom or hidden in tablet and mobile views. I feel adding multiple ToCs (e.g. one in
beforeBody
one inright
) may be a common scenario worth supporting.This fix might be a bit hacky, but I don't know how to generate dynamic IDs and deal with ARIA and styling otherwise. Please feel free to supersede this PR with a better fix.
A note about other components that are broken when added twice
Explorer is another obvious example, if one is to add a second one in
afterBody
for the mobile view, that one is not collapsible.But I'd think #1471 is a much better solution for Explorer. Perhaps in the future it can be extended so that the hamburger menu becomes a new Quartz layout component (although I'd think double-adding components would become more of an issue to be solved then; it was briefly discussed in the original layout rework PR I was looking forward to: #1339).
EDIT: This PR appears to overlap with #1338 a bit. 1338 fixes the Explorer and ToC's collapse function, but doesn't fix ToC's title highlight function.