-
Notifications
You must be signed in to change notification settings - Fork 201
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
Left ToC open on mobile during page load #366
Comments
Yeh the JS is here:
this could, and should, be achieved by CSS |
Yeah it's always been like this, and agreed it is definitely sub optimal. I feel like part of the answer is finding a more graceful way to handle the opening and closing logic (IMO it would be great if we could avoid JS altogether but I wasn't sure how to do this at the time) |
I tried to see if this would be a simple fix, but I got bogged down in the bootstrap JS/CSS stuff and ran out of time, so instead I've updated the top comment with some more explanation of what I think is going on here so it's easier to pick back up (myself or others) in the future |
FWIW, another option would be to have JS inline at the top of body / relevant tag, that adds the relevant class to it, to trigger the hiding (if the hiding worked that way) |
Description
When the book theme is loaded on narrow screens, the left navigation bar is briefly visible, and then collapses.
Instead, it should automatically be invisible on narrow screens, and pressing the "show navbar" button should show it. Basically, similar to how Furo works:
)
Why does this happen
This happens because we are currently using Bootstrap Collapse functionality to toggle the left navigation bar. Clicking the button will use the bootstrap classes
.collapse
,.collapsing
, and.show
to trigger two things:The problem with this is that we want a different default behavior on wide vs. narrow screens. On wide screens, the sidebar should be visible by default, with the option to hide. On narrow screens we want it hidden by default, with option to show (and ideally, hiding can be done by clicking anywhere outside the sidebar, not just on the toggle button).
How could we solve this?
I think the easiest way to solve this would be to do a few things:
.show-toggle
and a simpleonclick
function likegetElementById('site-navigation').classList.toggle("show-toggle")
@media
queries in our CSS (so thatchecked
means "show it" on mobile, but means "hide it" on wide screens)The text was updated successfully, but these errors were encountered: