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
Fix/6475 Table of Contents overflowing side of window and global footer #140
Conversation
f340d58
to
830fb7b
Compare
830fb7b
to
8a02230
Compare
top: $single-handbook-toc-position-top; | ||
max-height: calc(90vh - #{ $single-handbook-toc-position-top }); | ||
} | ||
} | ||
} | ||
|
||
@media (min-width: 877px) { | ||
// Pages which are not code reference and without a sidebar |
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.
This was required for local dev, but in production all pages have a sidebar on the left so this code is redundant
In several browsers there is a delay before the scroll position is restored. This results in the ToC not being repositioned if the page is refreshed when scrolled to the bottom. Lodash Throttle provides support for `trailing` events to always be fired, which fixes the issue, whereas rafThrottle does not.
In regards to the footer overlap, since the TOC shows up at the right level relative to the document, could we utilize Example: In the example, I just changed to sticky positioning and relied on a negative |
Hmm nice idea, I'll try it out thanks |
a28e6ee
to
08a810d
Compare
08a810d
to
9f6df36
Compare
@@ -2243,7 +2243,6 @@ div[class*="-table-of-contents-container"] { | |||
background: linear-gradient(to right, #fafafa 35%, #fff 35%); | |||
max-width: 100%; | |||
padding: 0; | |||
overflow: auto; |
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.
A parent with this property stops position: sticky
working on children. I'm unsure why it's being set and haven't observed any changes as a result of removing it.
👍 Seems to work well @StevenDufresne, please give it a try |
Yep, this is working as expected. Good job! |
Fixes https://meta.trac.wordpress.org/ticket/6475
2 issues are fixed by this PR:
For 2 a script has been added which detects if the ToC is overlapping the footer on
scroll
andresize
, and if so shifts it up above.lodash.throttle
has been used to throttle the events, as opposed torequestAnimationFrame
, as it providestrailing
event support. This proved necessary in many browsers where there is a delay in restoring the scroll position after refreshing, and rAF throttling blocked these delayed events, resulting in the ToC not being repositioned on refresh when scrolled to the bottom of the page.As there is no build process for JS in this repo I've opted for es6 local
import
, but we could introduce a build instead. I think browser support is good enough for this, based on our support policy and https://caniuse.com/es6-module-dynamic-importScreenshots
Horizontal overflow
Footer overlap
Before
After
How to test
NOTE: at smaller sizes the ToC will not be fixed outside the content, and the layout should not be effected by the new changes.
NOTE: locally the lefthand sidebar may not be displayed on these pages (it's not for me). To mimic the actual behaviour in prod you can comment out the return on this line: https://github.com/WordPress/wporg-developer/blob/trunk/source/wp-content/themes/wporg-developer/sidebar-handbook.php#L9