Skip to content

Commit 226e758

Browse files
committed
Fix bug with ResizeObserver in table of contents
1 parent 210d434 commit 226e758

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/layouts/ContentsLayout.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ function TableOfContents({ tableOfContents, currentSection }) {
128128
}
129129

130130
function getTop(id) {
131-
return document.getElementById(id).getBoundingClientRect().top + window.scrollY
131+
let el = document.getElementById(id)
132+
return el ? el.getBoundingClientRect().top + window.scrollY : 0
132133
}
133134

134135
function useTableOfContents(tableOfContents) {

0 commit comments

Comments
 (0)