Skip to content

Commit

Permalink
Addon-docs: Make Table of Content click handler safer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidnioulz committed Dec 24, 2024
1 parent c9d5743 commit f07cf4a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/lib/blocks/src/components/TableOfContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ export const TableOfContents = ({
e.preventDefault();
if (e.currentTarget instanceof HTMLAnchorElement) {
const [, headerId] = e.currentTarget.href.split('#');
channel.emit(NAVIGATE_URL, `#${encodeURIComponent(headerId)}`);
if (headerId) {
channel.emit(NAVIGATE_URL, `#${encodeURIComponent(headerId)}`);
}
}
},
...unsafeTocbotOptions,
Expand Down

0 comments on commit f07cf4a

Please sign in to comment.