fix(charts): preserve map pan/zoom on re-render + reflect graph node selection - #1113
Conversation
…selection Map (P1, user-visible): the marker-build effect re-ran on every parent re-render because two of its deps got a fresh identity each render — the plugin's inline onMarkerClick arrow and the inline [20,20] fitBoundsPadding default. Each run tore down + rebuilt every marker AND called fitBounds, snapping the user's pan/zoom back (autoFitBounds defaults to true). Fix: latest-ref the click handler, hoist the padding default to a module const, and split auto-fit into its own effect keyed on [markers, autoFitBounds, fitBoundsPadding] so rebuilding markers never re-fits. Re-fit now happens only when markers actually change. Graph (P2): selectedNodeIds was passed in and toggled by the click handler but never mapped to NVL's `selected` field, so controlled/restored selection had no visual effect. Map it in toNvlNode (Set membership) and add to the nvlNodes memo deps. NVL's BasicNvlWrapper diffs attributes and applies via addAndUpdateElementsInGraph, so selection updates incrementally without re-running layout. component unit suite: 1474 pass (+7 new); tsc clean; lint 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughTwo bug fixes with accompanying tests: ChangesMapChart pan/zoom stability fix
GraphChart selection state visual fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: one or more packages not found in the registry. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Graph + map — deep functional review
Continuation of the v1.1 component review. After the per-chart design/a11y pass, this is a deep functional review of the two most complex charts, where remaining bugs were likeliest to hide.
🔴 P1 — Map: pan/zoom reset + full marker rebuild on every parent re-render
The marker-build
useEffectre-ran on every render because two deps got a fresh identity each render: the plugin's inlineonMarkerClickarrow, and the inline[20, 20]fitBoundsPaddingdefault. Each run tore down + rebuilt every marker and calledmap.fitBounds(...)— snapping the user's pan/zoom back to the data bounds.autoFitBoundsdefaults totruein the map plugin, so any unrelated re-render (parameter change, auto-refresh poll, hover) yanked the map back.Fix: latest-ref the click handler (no longer an effect dep); hoist the padding default to a module constant (
DEFAULT_FIT_PADDING); split auto-fit into its own effect keyed on[markers, autoFitBounds, fitBoundsPadding]. Re-fit now happens only when markers actually change → user pan/zoom is preserved.🟠 P2 — Graph:
selectedNodeIdshad no visual effectgraph-exploration-wrapperpassesselectedNodeIdsand the click handler toggles it, buttoNvlNodenever mapped it to NVL'sselectedfield — so a restored/programmatic selection never highlighted the node (selection was one-way-out only).Fix: build a
SetfromselectedNodeIdsand setselectedintoNvlNode; add to thenvlNodesmemo deps.BasicNvlWrapperdiffs node attributes and applies viaaddAndUpdateElementsInGraph, so selection updates incrementally without re-running layout (no graph reshuffle on click — verified against the NVL wrapper source).⚪ Verified, not bugs
popupHTML binding is a trusted public-API choice — the app'stransformToMapDatanever setspopup, and the data-drivenpropertiestooltip path is escaped. No app XSS.Verification
componentunit suite: 1474 pass (+7 new covering exactly the changed behavior) ·tsc --noEmitclean ·npm run lint0 errors.charts/heavy-widgets/widget-states/styling-rules→ 61 passed, 6 failed. All 6 failures areAuthPage.login/waitForURL/ pre-render timeouts — the documented [P2] e2e: local suite flaky above 2 workers — cap local parallelism or document it #994 server/DB-contention flakes, failing at the auth/navigation stage before any graph/map widget renders (categorically unreachable by these component changes). Isolation re-runs were blocked by a 1-CPU Docker host that can't start the Neo4j testcontainer within 120s (Neo4j took >6 min to start standalone here). CI E2E is the authoritative gate.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests