Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

@media (min-width: 997px) {
.expandButton {
position: sticky;
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
max-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +63 to +68

Copy link
Copy Markdown
Contributor Author

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.

sidebar={sidebar}
path={pathname}
onCollapse={toggleSidebar}
isHidden={hiddenSidebar}
/>
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put .expandButton inside .sidebarViewport (outside .sidebar).

</div>
</ResetOnSidebarChange>

{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
</aside>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.sidebarViewport is a sticky element that's clamped to screen height. Its width will shrink on collapse.
.sidebarViewport, .sidebar, and .expandButton elements will have the same height (on collapse & expand).

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -24,8 +20,6 @@

.sidebarHidden {
opacity: 0;
height: 0;
overflow: hidden;
visibility: hidden;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.sidebar will not shrink in size on collapse anymore. It will just become invisible. This preserves the height.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.


Expand Down