Skip to content

Commit 36433af

Browse files
authored
Merge pull request #567 from raifdmueller/fix/subanchor-modal-close
fix(modal): sub-anchor click closes the umbrella modal (E2E regression)
2 parents 55ce9e7 + 1baa45c commit 36433af

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

website/src/components/anchor-modal.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,16 @@ export async function loadAnchorContent(anchorId) {
289289
details.setAttribute('open', '')
290290
})
291291

292-
// Convert internal AsciiDoc cross-reference links to router navigation
293-
contentEl.querySelectorAll('a[href^="#"]').forEach((link) => {
292+
// Convert internal AsciiDoc cross-reference links to router navigation.
293+
// Exclude sub-anchor links (handled above) — they share the href="#" shape
294+
// and would otherwise also fire navigate('/anchor/') with an empty id,
295+
// which the router treats as a non-anchor route and closes the modal.
296+
contentEl.querySelectorAll('a[href^="#"]:not([data-sub-anchor])').forEach((link) => {
294297
const href = link.getAttribute('href')
295-
// Only process simple hash links (cross-references), not hash routes
298+
// Only process real cross-references: a non-empty id, not a hash route.
296299
if (href && href.startsWith('#') && !href.startsWith('#/')) {
297300
const anchorId = href.substring(1) // Remove the '#'
301+
if (!anchorId) return
298302
link.addEventListener('click', (e) => {
299303
e.preventDefault()
300304
// Navigate to the linked anchor

0 commit comments

Comments
 (0)