File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
2- import type { Props } from ' @astrojs/starlight/props' ;
32import Default from ' @astrojs/starlight/components/SocialIcons.astro' ;
43const base = import .meta .env .BASE_URL ;
54---
@@ -129,7 +128,13 @@ const base = import.meta.env.BASE_URL;
129128</style >
130129
131130<script >
131+ let hamburgerAbort: AbortController | undefined;
132+
132133 function initHamburgerMenu() {
134+ hamburgerAbort?.abort();
135+ hamburgerAbort = new AbortController();
136+ const { signal } = hamburgerAbort;
137+
133138 const hamburgerBtn = document.querySelector<HTMLButtonElement>('.hamburger-btn');
134139 const tabletDropdown = document.querySelector<HTMLElement>('.tablet-dropdown');
135140
@@ -144,22 +149,22 @@ const base = import.meta.env.BASE_URL;
144149 const firstLink = tabletDropdown.querySelector<HTMLAnchorElement>('.dropdown-link');
145150 firstLink?.focus();
146151 }
147- });
152+ }, { signal } );
148153
149154 document.addEventListener('click', (e) => {
150155 if (!hamburgerBtn.contains(e.target as Node) && !tabletDropdown.contains(e.target as Node)) {
151156 hamburgerBtn.setAttribute('aria-expanded', 'false');
152157 tabletDropdown.hidden = true;
153158 }
154- });
159+ }, { signal } );
155160
156161 document.addEventListener('keydown', (e) => {
157162 if (e.key === 'Escape' && hamburgerBtn.getAttribute('aria-expanded') === 'true') {
158163 hamburgerBtn.setAttribute('aria-expanded', 'false');
159164 tabletDropdown.hidden = true;
160165 hamburgerBtn.focus();
161166 }
162- });
167+ }, { signal } );
163168 }
164169
165170 initHamburgerMenu();
You can’t perform that action at this time.
0 commit comments