Skip to content

Commit f66744e

Browse files
authored
Merge pull request #2376 from mateuszbartosik/RDoc-3611
RDoc-3611 Fix scroll for TOC
2 parents 9aeef89 + 27684d4 commit f66744e

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/css/custom.css

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,16 @@ hr {
539539
}
540540

541541
/* Custom styling for TOC */
542+
.toc-desktop {
543+
--toc-desktop-top: 110px;
544+
--toc-desktop-bottom-offset: 4rem;
545+
position: sticky;
546+
top: var(--toc-desktop-top);
547+
}
548+
542549
.table-of-contents {
543-
padding: 0;
550+
@apply p-0 overflow-y-auto;
551+
max-height: calc(100vh - var(--toc-desktop-top) - var(--toc-desktop-bottom-offset));
544552
}
545553

546554
.table-of-contents__link {
@@ -625,33 +633,38 @@ a {
625633

626634
/* The track (progress bar) of the scrollbar */
627635
::-webkit-scrollbar-track {
628-
background-color: transparent;
636+
background-color: transparent !important;
629637
}
630638

631639
/* The entire scrollbar */
632640
::-webkit-scrollbar {
633-
width: 12px;
634-
height: 12px;
641+
width: 12px !important;
642+
height: 12px !important;
635643
}
636644

637645
/* The draggable scrolling handle. */
638646
::-webkit-scrollbar-thumb {
639-
border-radius: 8px;
640-
border: 4px solid transparent;
641-
background-clip: content-box;
642-
background-color: oklch(0.35 0 0 / 1);
647+
border-radius: 8px !important;
648+
border: 4px solid transparent !important;
649+
background-clip: content-box !important;
650+
background-color: oklch(0.35 0 0 / 1) !important;
643651
}
644652

645653
::-webkit-scrollbar-thumb:hover {
646-
background-color: oklch(0.4 0 0 / 1);
654+
background-color: oklch(0.4 0 0 / 1) !important;
647655
}
648656

649657
::-webkit-scrollbar-thumb:active {
650-
background-color: var(--ifm-color-primary);
658+
background-color: var(--ifm-color-primary) !important;
651659
}
652660

653661
::-webkit-scrollbar-corner {
654-
background-color: inherit;
662+
background-color: inherit !important;
663+
}
664+
665+
/* Override scrollbar for sidebar menu */
666+
.menu.thin-scrollbar {
667+
scrollbar-width: auto !important;
655668
}
656669

657670
/* Custom styles for See also path collapse */

src/theme/DocItem/TOC/Desktop/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function DocItemTOCDesktop(): ReactNode {
99
const filteredToc = useFilteredToc(toc);
1010

1111
return (
12-
<div className="sticky top-[160px]">
12+
<div className="toc-desktop">
1313
<p className="!mb-1 font-semibold">In this article</p>
1414
<TOC
1515
toc={filteredToc}

0 commit comments

Comments
 (0)