fix: prevent anchor link from being a link

This commit is contained in:
Oliver Booth 2024-04-27 00:31:11 +01:00
parent 720b636439
commit b119861eee
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
2 changed files with 4 additions and 2 deletions

View File

@ -87,7 +87,7 @@ internal sealed class CodeSnippetTemplateRenderer : CustomTemplateRenderer
data-tab-init
class="nav-link{classList}"
id="snp-{snippetId}-{identifier:N}-{language}-l"
href="#snp-{snippetId}-{identifier:N}-{language}"
href="#"
role="tab"
data-tabs="snp-{snippetId}-{identifier:N}"
aria-controls="snp-{snippetId}-{identifier:N}-{language}"

View File

@ -159,7 +159,9 @@ class UI {
const tabPanes = element.querySelectorAll(`.tab-pane[data-identifier="${identifier}"]`);
tabLinks.forEach(function (tabLink: Element) {
tabLink.addEventListener("click", () => {
tabLink.addEventListener("click", (ev: Event) => {
ev.preventDefault();
const controls = document.getElementById(tabLink.getAttribute("aria-controls"));
// switch "active" tab link