Skip to content

Commit

Permalink
fix unrelated bug in use-active-section
Browse files Browse the repository at this point in the history
  • Loading branch information
zchsh committed Jul 22, 2024
1 parent 14ea2b7 commit 821bcac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/hash-links/use-active-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function useActiveSection(
let closestHeading
visibleHeadings.current.forEach((headingId) => {
const targetElement = document.getElementById(headingId)
const distance = targetElement.getBoundingClientRect().bottom
const distance = targetElement?.getBoundingClientRect().bottom
if (!closestHeading || distance < shortestDistance) {
closestHeading = headingId
shortestDistance = distance
Expand Down

0 comments on commit 821bcac

Please sign in to comment.