pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

fix: scope edge movement to current graph

Open caydyan opened this issue 5 months ago • 1 comments

Summary

Fixes #513.

Edges were being moved with document.querySelector('.svelvet-graph-wrapper'), which always returns the first Svelvet graph wrapper on the page. In pages with multiple Svelvet instances, that caused edges from later instances to be appended into the first graph.

This changes edge movement to use edgeElement.closest('.svelvet-graph-wrapper'), so each edge is appended to the graph wrapper it was rendered inside. It also avoids removing the edge when it is already parented by the correct wrapper.

Test coverage

Added a jsdom unit test that builds two .svelvet-graph-wrapper containers and verifies an edge from the second wrapper stays under that second wrapper instead of moving to the first one.

Validation

  • npm run test:unit -- tests/unit-tests/components/edgeMove.test.ts
  • npm run test:unit
  • npx prettier --check src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.ts
  • npx eslint src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.ts
  • npm run build

Known existing failure:

  • npm run check still reports the existing repo-wide 64 errors / 5 warnings in unrelated files such as DrawerController.svelte, createGraph.ts, route examples, and existing tests.

Sphinx bounty #2284 payout address: bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc.

caydyan avatar Jun 14 '26 08:06 caydyan

Current-head validation rerun on 88b58e5f4cfdcec9074c6a9632ec6d5d008e1d3d:

  • git diff --check origin/main...HEAD
  • npm run test:unit -- tests/unit-tests/components/edgeMove.test.ts (1 test passed)
  • npm run test:unit (5 suites / 10 tests passed)
  • npx prettier --check src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.ts
  • npx eslint src/lib/components/Edge/Edge.svelte tests/unit-tests/components/edgeMove.test.ts
  • npm run build (build/package/publint completed; existing route a11y/unused CSS warnings only)

Local worktree is clean after the rerun.

caydyan avatar Jun 14 '26 18:06 caydyan