Skip to content

Commit 4844271

Browse files
authored
Merge pull request #6495 from EnterpriseDB/bugfix/josh/DOCS-878-fix-the-infinite-scroll-bar-for-toc
DOCS-878: Use max-height instead of height
2 parents 6ec6b69 + 442928e commit 4844271

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

src/components/table-of-contents.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
import React from "react";
1+
import React, { useEffect, useState } from "react";
22
import { Link } from "./";
33
import { useScrollRestoration } from "gatsby";
4-
import { useLocation } from "@reach/router";
4+
import { useLocation } from "@gatsbyjs/reach-router";
55

66
const TableOfContents = ({ toc, deepToC }) => {
77
const scrollRestoration = useScrollRestoration("header-navigation-sidebar");
8-
const hash = useLocation().hash;
8+
const loc = useLocation();
9+
const [hash, setHash] = useState("");
10+
11+
useEffect(() => {
12+
setHash(loc.hash);
13+
}, [loc]);
914

1015
return (
11-
<ul
12-
className="list-unstyled border-start ps-4 lh-12 toc-sticky pt-3"
13-
{...scrollRestoration}
14-
>
16+
<ul className="list-unstyled lh-12 toc-sticky pt-3" {...scrollRestoration}>
1517
<li className="mb-2 fw-bold text-muted text-uppercase small">
1618
On this page
1719
</li>
1820
{toc
1921
.filter((item) => item.title)
2022
.map((item) => (
21-
<li key={item.title}>
23+
<li key={item.url || item.title}>
2224
<Link
2325
className={`d-block py-2 align-middle ${
2426
hash === item.url ? "active" : deepToC ? "fw-normal" : ""
@@ -32,7 +34,7 @@ const TableOfContents = ({ toc, deepToC }) => {
3234
{item.items
3335
.filter((subitem) => subitem.title)
3436
.map((subitem) => (
35-
<li key={subitem.title}>
37+
<li key={subitem.url || subitem.title}>
3638
<Link
3739
className={`d-block py-1 align-middle ${
3840
hash === subitem.url ? "active" : "fw-lighter"

src/styles/_docs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ label.link-label {
102102
}
103103

104104
.content-container {
105-
max-width: 1080px;
105+
max-width: 1344px;
106106
margin: 0 auto;
107107
}
108108

src/styles/_overrides.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
.toc-sticky {
1212
position: sticky;
1313
top: 0;
14-
height: 100vh;
14+
max-height: 100vh;
1515
overflow-x: hidden;
1616
overflow-y: auto;
1717
}

src/templates/doc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ const DocTemplate = ({ data, pageContext }) => {
288288
</Col>
289289

290290
{showToc && (
291-
<Col className="d-xs-none col-lg-3 d-print-none">
291+
<Col className="d-none d-lg-block col-lg-3 d-print-none border-start">
292292
<TableOfContents toc={newtoc} deepToC={deepToC} />
293293
</Col>
294294
)}

src/templates/learn-doc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ const LearnDocTemplate = ({ data, pageContext }) => {
211211
</Col>
212212

213213
{showToc && (
214-
<Col className="d-xs-none col-lg-3 d-print-none">
214+
<Col className="d-none d-lg-block col-lg-3 d-print-none border-start">
215215
<TableOfContents toc={newtoc} deepToC={deepToC} />
216216
</Col>
217217
)}

0 commit comments

Comments
 (0)