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(theme): preserve sidebar height on collapse #8328
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,15 +60,20 @@ export default function DocRootLayoutSidebar({ | |
} | ||
}}> | ||
<ResetOnSidebarChange> | ||
<DocSidebar | ||
sidebar={sidebar} | ||
path={pathname} | ||
onCollapse={toggleSidebar} | ||
isHidden={hiddenSidebar} | ||
/> | ||
<div | ||
className={clsx( | ||
styles.sidebarViewport, | ||
hiddenSidebar && styles.sidebarViewportHidden, | ||
)}> | ||
<DocSidebar | ||
sidebar={sidebar} | ||
path={pathname} | ||
onCollapse={toggleSidebar} | ||
isHidden={hiddenSidebar} | ||
/> | ||
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put |
||
</div> | ||
</ResetOnSidebarChange> | ||
|
||
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />} | ||
</aside> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,11 @@ | |
width: var(--doc-sidebar-hidden-width); | ||
cursor: pointer; | ||
} | ||
|
||
.sidebarViewport { | ||
top: 0; | ||
position: sticky; | ||
height: 100%; | ||
max-height: 100vh; | ||
} | ||
Comment on lines
+33
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,9 @@ | |
.sidebar { | ||
display: flex; | ||
flex-direction: column; | ||
max-height: 100vh; | ||
height: 100%; | ||
position: sticky; | ||
top: 0; | ||
padding-top: var(--ifm-navbar-height); | ||
width: var(--doc-sidebar-width); | ||
transition: opacity 50ms ease; | ||
} | ||
|
||
.sidebarWithHideableNavbar { | ||
|
@@ -24,8 +20,6 @@ | |
|
||
.sidebarHidden { | ||
opacity: 0; | ||
height: 0; | ||
overflow: hidden; | ||
visibility: hidden; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, looks better indeed 👍 Wonder if it affects accessibility and keyboard navigation? Is it possible now to navigate with the keyboard (tabs) on these hidden elements? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slorber That's a good point. I haven't tested keyboard navigation on hidden elements. |
||
|
||
|
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.
Wrap the
.sidebar
element with a new.sidebarViewport
element.