Skip to content

Commit

Permalink
even better
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Apr 1, 2023
1 parent f9fbb37 commit d2a25a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/src/modules/components/AppNavDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ ProductIdentifier.propTypes = {
versionSelector: PropTypes.element,
};

// To match scrollMarginBottom
const browserUrlPreviewHeight = 30;

function PersistScroll(props) {
Expand All @@ -142,7 +143,8 @@ function PersistScroll(props) {
const activeBox = activeDrawerLink.getBoundingClientRect();

if (activeBox.top < 0 || activeBox.bottom + browserUrlPreviewHeight > window.innerHeight) {
scrollContainer.scrollTop += activeBox.top - (activeBox.bottom - activeBox.top) * 1.5;
// Scroll the least possible from the initial render, e.g. server-side, scrollTop = 0.
activeDrawerLink.scrollIntoView(false);
}

return () => {
Expand Down
2 changes: 2 additions & 0 deletions docs/src/modules/components/AppNavDrawerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ const Item = styled(
paddingLeft: 2,
}),
'&.app-drawer-active': {
// To match browserUrlPreviewHeight
scrollMarginBottom: 30,
color: (theme.vars || theme).palette.primary[600],
backgroundColor: (theme.vars || theme).palette.primary[50],
'&:hover': {
Expand Down

0 comments on commit d2a25a8

Please sign in to comment.