Skip to content

Commit 1baa45c

Browse files
raifdmuellerclaude
andcommitted
fix(modal): sub-anchor click no longer closes the umbrella modal
Sub-anchor links render as <a href="#" data-sub-anchor>, which were also matched by the AsciiDoc cross-reference handler (a[href^="#"]). Clicking a sub-anchor therefore fired both its own handler AND a bogus navigate('/anchor/') with an empty id. Harmless before, but since the modal now closes when a non-anchor route resolves (#565), handleRoute normalizes '/anchor/' → '/anchor' (not an anchor route) and closed the umbrella modal — breaking the "navigate to sub-anchor / show back button" E2E tests. Exclude data-sub-anchor links from the cross-reference handler and ignore empty ids, so sub-anchor clicks only load the sub-anchor and the modal + back button stay put. Verified: full E2E suite (35) green locally, incl. the two umbrella tests that regressed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 55ce9e7 commit 1baa45c

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)