The fix in issue #2 resolved a stale-closure bug in createPathSegment where
onClick captured graphsPath at render time; after further navigation findIndex
returned -1 and splice(0) wiped the entire breadcrumb array.
New test suite 'Stale-closure regression (issue #2)' covers:
- Root breadcrumb remains functional after navigating three levels deep
- Level-1 breadcrumb resolves correctly when clicked from level 3
- Successive back-clicks each trim exactly one breadcrumb level
- Clicking the currently active breadcrumb does not alter the path
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The onClick handler in createPathSegment closed over the graphsPath variable
from the render when the segment was created. By the time a breadcrumb was
clicked (after further navigation), that closure was stale, so findIndex
returned -1 and splice(0) wiped the entire breadcrumb array.
Fix: use the functional updater form of setGraphsPath so findIndex runs
against the current state rather than a stale snapshot.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Right-clicking on empty graph area (outside any node or edge) now shows
a context menu with a single 'Create Node' option. Clicking it adds a new
node with a random label and no edges, allowing the user to wire it up
manually afterwards.
- NodeContext gains isEmptyArea flag to distinguish empty-area from node
right-clicks
- Container div contextmenu handler covers the white space below the SVG;
SVG-level handler covers empty space within the rendered graph
- node contextmenu handler calls stopPropagation so the SVG handler never
fires for node clicks; SVG handler also guards via target.closest check
- NodeContextMenu renders emptyAreaItems (Create Node only) vs nodeItems
(Rename / Subgraph / Remove) based on the flag
- randomWordList extracted as a named export so NodeContextMenu can reuse
the same word bank
- Three new Playwright e2e tests cover: empty-area menu shows only Create
Node, created node is orphaned (no new edges), node right-click does not
show Create Node