Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ node_modules/
!website/public/hmze-logo.png
!docs/workflow-diagram.svg
.playwright-mcp/
.venv/
.linkedin/
*:Zone.Identifier
website/public/CONTRIBUTING.html
website/public/CONTRIBUTING.de.html
8 changes: 4 additions & 4 deletions website/src/components/anchor-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ export async function loadAnchorContent(anchorId) {
}

export function showAnchorDetails(anchorId) {
const modal = document.getElementById('anchor-modal')
if (modal) {
modal.dataset.currentAnchor = anchorId
}
// Share-link race: handleRoute may invoke us before initApp's createModal()
// microtask runs. createModal is idempotent.
const modal = document.getElementById('anchor-modal') || createModal()
modal.dataset.currentAnchor = anchorId
openModal()
return loadAnchorContent(anchorId)
}
Expand Down
16 changes: 16 additions & 0 deletions website/src/components/anchor-modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ describe('anchor-modal', () => {
const content = document.getElementById('modal-content')
expect(content.innerHTML).toContain('Failed to load')
})

it('should not crash when modal element is missing (share-link race, #470)', async () => {
const existing = document.getElementById('anchor-modal')
if (existing) existing.remove()

global.fetch.mockResolvedValue({
ok: true,
text: async () => '= Test Anchor\n\nTest content',
})

await expect(showAnchorDetails('test-anchor')).resolves.not.toThrow()

const modal = document.getElementById('anchor-modal')
expect(modal).not.toBeNull()
expect(modal.classList.contains('hidden')).toBe(false)
})
})

describe('umbrella anchors', () => {
Expand Down
Loading