Skip to content

Commit 06615e1

Browse files
authored
Merge pull request #53 from disberd/copilot/fix-unhide-icon-failure
Fix ExtendedTableOfContents unhide icon crash on null cell reference
2 parents 98d0f05 + d2ece3a commit 06615e1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/extended_toc/extended_toc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,13 @@ header.addEventListener('mouseenter', (e) => {
724724
notebook_hide_icon.addEventListener('click', (e) => {
725725
// We find the x coordinate of the pluto-notebook element, to avoid missing the cell when UI is disabled
726726
const { x } = document.querySelector('pluto-notebook').getBoundingClientRect()
727-
const ref = document.elementFromPoint(x+1,100).closest('pluto-cell')
728-
const { y } = ref.getBoundingClientRect()
727+
const ref = document.elementFromPoint(x+1,100)?.closest('pluto-cell')
728+
const y = ref?.getBoundingClientRect().y
729729
toggle_notebook_attribute('hide-enabled')
730-
const dy = ref.getBoundingClientRect().y - y
731-
window.scrollBy(0, dy)
730+
if (ref != null && y != null) {
731+
const dy = ref.getBoundingClientRect().y - y
732+
window.scrollBy(0, dy)
733+
}
732734
})
733735

734736
// Save to file functionality

0 commit comments

Comments
 (0)