Skip to content

Fixes 36362: Lineage node drag held at the canvas edge no longer crashes - #36901

Merged
chirag-madlani merged 6 commits into
mainfrom
chirag-madlani/lineage-uncontrolled-drag
Nov 3, 2026
Merged

chirag-madlani merged 6 commits into
mainfrom
chirag-madlani/lineage-uncontrolled-drag

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #36362

Dragging a lineage node and holding it at the canvas edge (so React Flow auto-pans) could crash the page with "Maximum update depth exceeded".

Both lineage canvases passed controlled nodes to React Flow v11, so every drag frame went through onNodesChange into React state and back into React Flow's store. During auto-pan that happened several times per animation frame. This PR makes node drags uncontrolled until the drop, as the issue proposes:

  • Drag frames update React Flow's store only. The caller's onNodesChange gets no drag frames, only the drop, with the final position filled in.
  • A parent re-render mid-drag (a hover highlight on the platform map, a node measured after auto-pan) cannot snap the dragged node back or let the drop save its start position. The hook lays the in-flight positions over the nodes passed to <ReactFlow>.
  • While a node is dragged, only that node's edges are hidden. They come back on the drop; all other edges keep drawing.
  • The edge canvas keeps repainting while auto-pan runs. It used to freeze until the drop, because each viewport change cancelled the pending redraw frame and React Flow's auto-pan changes the viewport every frame.

Type of change:

  • Bug fix

High-level design:

  • hooks/lineage/useUncontrolledNodeDrag.ts (new): wraps the caller's onNodesChange.
    • Drag frames (position with dragging: true) are applied to React Flow's store with store.setNodes and remembered in a ref.
    • The drop change, which React Flow sends without a position, gets the last drag position.
    • The hook returns nodes with in-flight positions overlaid, so a caller re-render never hands React Flow pre-drag positions.
    • A drag cancelled with no drop (a second finger on a touch screen) is settled where it was left when the next drag starts: its dragging flag is cleared in React Flow's store and its last position is reported once.
    • Keyboard moves, selection, dimensions and add/remove pass through unchanged.
  • components/Lineage/UncontrolledDragFlow/UncontrolledDragFlow.tsx (new): a <ReactFlow> that applies the hook. It renders inside EntityLineageCanvas's existing ReactFlowProvider.
    • Hoisting the provider instead broke a Playwright test: the canvas swaps to a skeleton on every fetch, which used to give React Flow a fresh store, and a hoisted provider kept a stale one.
  • LineageMap.component.tsx: the platform map has the same controlled pattern and calls the hook inline, because its <ReactFlow> takes a ref.
  • useCanvasEdgeRenderer.ts, EdgeMidpointUtils.ts, CanvasEdgeRenderer.component.tsx:
    • Edges whose source or target React Flow marks dragging are skipped when drawing and hit-testing, through the new isEdgeOnDraggedNode helper.
    • The Playwright-only edge markers recompute from React Flow's nodes, so they match what is drawn mid-drag.
    • The redraw effect no longer cancels a scheduled frame when its dependencies change; the frame reads the latest state through a ref. It is cancelled only on unmount.
  • Decision record: ADR:2026-11-03-lineage-node-drags-stay-in-react-flow-until-drop states the contract. During a drag, positions live only in React Flow's store, and only the dragged node's edges are hidden.
  • Alternatives considered:
    • autoPanOnNodeDrag={false} removes the trigger but changes the UX.
    • Moving to @xyflow/react v12 is a larger migration.
  • Rollout: no migration or backward-compatibility concerns.

Tests:

Use cases covered

  • Holding a dragged node at the canvas edge auto-pans without crashing, and the node stays where it is dropped.
  • Only the dragged node's edges hide during the drag; a sibling edge keeps drawing; the hidden edges return on the drop.
  • A parent re-render mid-drag keeps the dragged node in place and the drop saves the dragged position.
  • A touch drag cancelled by a second finger (no drop) is settled where it was left once another drag starts, and its edges come back.
  • The edge canvas keeps repainting while a dragged node auto-pans the canvas.
  • Keyboard moves and non-drag changes reach the caller unchanged.

Unit tests

  • I added unit tests for the new/changed logic.
  • New:
    • src/hooks/lineage/useUncontrolledNodeDrag.test.tsx
    • src/components/Lineage/UncontrolledDragFlow/UncontrolledDragFlow.test.tsx (real React Flow store, drives updateNodePositions)
    • src/utils/EdgeMidpointUtils.test.ts
  • Updated:
    • src/hooks/useCanvasEdgeRenderer.test.ts (skips only a dragged node's edges; a dependency change does not cancel a scheduled draw)
    • CanvasEdgeRenderer.component.test.tsx
    • EntityLineageCanvas.test.tsx
  • Mutation-checked: reverting the overlay, the drop fill-in, the wrapper's use of the hook, the edge filter, the cancelled-drag settling, or the redraw fix each fails a test.
  • Coverage (Jest):
    • useUncontrolledNodeDrag.ts: 100% lines, 93.75% branches
    • UncontrolledDragFlow.tsx: 100%
    • useCanvasEdgeRenderer.ts: 85.9% lines (the uncovered lines are pre-existing code this PR doesn't touch)
  • yarn test src/utils/EdgeMidpointUtils src/components/Lineage src/hooks/lineage src/hooks/useCanvasEdgeRenderer src/components/Entity/EntityLineage: 41 suites, 491 tests passed.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • I added Playwright E2E tests under openmetadata-ui/.../ui/playwright/ for UI changes.
  • Files: playwright/e2e/Pages/Lineage/LineageControls.spec.ts, new "Node drag" test.
    • It creates its own table → topic and table → table lineage, then drags the topic to the top edge and holds it until auto-pan has scrolled more than 1500px.
    • It checks that the topic's edge hides while the sibling edge stays, that the canvas survives, that the edge returns on the drop, and that the node stays where it was dropped.
  • Impact map: .github/playwright/impact-map.json now maps the new hook, edge-renderer and midpoint files to the lineage specs.
  • Where it ran: locally, against production builds of this branch, with /api proxied to a local OpenMetadata server.

1. Full impact-mapped selection (make playwright_affected_run, 692 tests, 88 min): 657 passed, 30 failed. Every failure was traced or rerun (see notes).

Spec Result
LineageControls (incl. "Node drag") · LineageInteraction · PlatformLineage · LineageRightPanel 9/9 · 23/23 · 8/8 · 11/11
LineageNodePagination · LineageLargeResponse · LineageTempTables · Flow/LineageSettings 5/5 · 1/1 · 1/1 · 3/3
LineageFilters 14/15 ¹
DataAssetLineage 94/100 ²
SearchRBAC · DomainIsolation (6 specs) · Navbar · DataMarketplace · Policies 29/29 · 16/16 · 22/22 · 5/5 · 3/3
SearchSettings · SearchRelevance · HealthCheck · DataAssetRulesEnabled 14/14 · 11/11 · 1/1 · 32/32
Dashboards · DataAssetRulesDisabled 3/4 ² · 27/28 ²
Entity.spec.ts 320/337 ³
IntakeForm · SystemCertificationTags · setup teardowns failed: server unreachable ²

2. Reruns on HEAD 1e404343f9a (production build, fresh setup / entity-data-setup):

Run Result
"Node drag" × 10, without this fix (main a20b39f) 3 of 10 crash with React #185 (Maximum update depth exceeded)
"Node drag" × 10 10/10
DataAssetLineage · Dashboards · DataAssetRulesDisabled (rerun in full) 101/101 · 4/4 · 34/34
LineageControls · LineageInteraction · PlatformLineage · LineageFilters 9/9 · 23/23 · 8/8 · 14/15 ¹
LineageLargeResponse · LineageNodePagination · LineageRightPanel · LineageTempTables · LineageSettings 1/1 · 5/5 · 11/11 · 1/1 · 3/3
Lineage-canvas specs outside the impact map: ImpactAnalysis · ExplorePageRightPanel · InputOutputPorts · Pagination 24/24 · 234/234 · 43/43 · 37/37
Navbar · DataMarketplace · Policies · SearchSettings · ExploreFilterSeparation 22/22 · 5/5 · 3/3 · 14/14 · 2/2

3. After the review fixes, on HEAD 9e219710f05 (cancelled-drag settling and the edge-canvas redraw fix):

Run Result
"Node drag" × 10 10/10
LineageControls · LineageInteraction · PlatformLineage · DataAssetLineage 9/9 · 23/23 · 8/8 · 101/101
LineageRightPanel · LineageNodePagination · LineageTempTables · LineageLargeResponse 11/11 · 5/5 · 1/1 · 1/1

¹ "verify downstream count for all the entities" expects Downstream 15 and fails the same way on the main build: re-seeding the local test data without a teardown leaves an extra edge on that root. This is local data, not this change.
² During the run I swapped the local build server it was using, so these tests got ECONNREFUSED or an app that never booted. The one DataAssetRulesDisabled failure was a 409 Entity already exists test-data collision. DataAssetLineage, Dashboards and DataAssetRulesDisabled all pass in full when rerun on HEAD (table 2).
³ "Domain Add, Update and Remove" for each entity type, plus one glossary-term test: the domain widget never renders on the asset page. The Table domain test fails the same way on the main build, so it is environmental, not this change.

Manual testing performed

  1. Ran yarn start against a local server (localhost:8585) and logged in as admin.
  2. Opened /table/sample_data.ecommerce_db.shopify.dim_customer/lineage?fullscreen=true, dragged a node to the top edge and held it. The view auto-panned, there was no crash, only that node's edges hid, and they came back on the drop with the node where it was dropped.
  3. On the platform Lineage page, dragged a node across other nodes (triggering hover highlights) and held it still. It stayed under the pointer, and the drop kept its position.

UI screen recording:

Recorded on commit 9e219710f05 (1440×900, 18 s, H.264).

lineage-drag-autopan-fix.mp4
  • Build: a production UI build (yarn build) of 9e219710f05, served with /api proxied to a local OpenMetadata server running in Docker (collate_server, healthy; GET /api/v1/system/version → 2.0.0-SNAPSHOT). The change is UI-only, so the server image does not carry it.
  • Fixture: created through the API in the shipped sample_data.ecommerce_db.shopify schema: tables orders_raw_* → orders_daily_* and orders_raw_* → orders_audit_*. Deleted after the recording.
  • Steps shown: open orders_raw_* lineage (full screen); drag orders_daily_* to the top edge and hold it there for about 4.5 s; drag it back into the canvas and drop it.
  • Outcomes, checked by the recording script:
    • only the dragged node's edge hides while the orders_audit_* edge keeps drawing and moves with the canvas;
    • auto-pan moves the canvas about 6,800 px with no crash and no error screen;
    • on the drop, the edge is drawn again and the node stays where it was dropped.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable (no schema change).

  • For a UI feature or feature task: not applicable (bug fix; see above).

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Three passes; the last ran on 68d1cf08e87 and found no 🔴.
    • Fixed 🔴: a mid-drag re-sync could snap the dragged node back and save its start position; fixed by overlaying in-flight positions on the nodes passed to React Flow.
    • Fixed 🔴: the missing decision record.
    • Fixed 🟡: a test that only checked the wrapper renders; no test for the edge filter; a cancelled touch drag kept its edges hidden (fixed in 1e404343f9a).
    • Copilot review: a cancelled drag left React Flow's store marking that node as dragging when the next drag began. Fixed in fdec4b48e2f, which settles such a drag where it was left; the test seeds the store and asserts the flag is cleared while the next node is still dragging.
    • Found while recording: the edge canvas froze during auto-pan (redraw starvation). Fixed in 9e219710f05, with a regression test.
    • Answered 🟡, LineageMap has no drag Playwright test: its scene nodes have no stable test ids. Its drag path goes through the same hook, which is covered by the hook and wrapper unit tests.
  • Decision check: adds docs/decisions/2026-11-03-lineage-node-drags-stay-in-react-flow-until-drop.md.

  • I have added a test that covers the exact scenario we are fixing (LineageControls.spec.ts › "Node drag", Lineage: node drag held at the canvas edge can crash with 'Maximum update depth exceeded' (make drag uncontrolled) #36362).

Controlled nodes sent every drag frame through React state and back into
React Flow's store. With auto-pan at the canvas edge that happened several
times per frame and could exceed React's nested-update limit ("Maximum
update depth exceeded"). Drag frames now update React Flow's store only,
and the final position is committed once on drop. Edges of the dragged
node are hidden until it is dropped.
…d-drag

A change forwarded mid-drag (React Flow measuring a node auto-pan just
revealed) made React Flow rebuild its store from the caller's nodes, which
still held pre-drag positions, so the dragged node snapped back and a quick
drop could save its start position. Such batches now carry the dragged
nodes' current positions. Map the new lineage hook and edge files to the
lineage Playwright specs.
…receives

Any parent re-render mid-drag (a hover highlight on the platform map, a
measured node) re-synced React Flow from nodes that still held pre-drag
positions, snapping the dragged node back and letting the drop save its
start position. The hook now remembers drag positions and overlays them on
the nodes passed to <ReactFlow>, replacing the in-flight change patch.
Record the drag contract as ADR:2026-11-03-lineage-node-drags-stay-in-react-flow-until-drop
and test that the canvas skips only a dragged node's edges.
A touch drag aborted by a second finger never sends a drop, so its node
kept an in-flight position and hidden edges. Each drag frame carries every
node being dragged, so the drag positions are rebuilt per frame.
Copilot AI balanced review requested due to automatic review settings November 3, 2026 06:51
@chirag-madlani
chirag-madlani requested a review from a team as a code owner November 3, 2026 06:51
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A cancelled touch drag leaves the previous node marked as dragging when another drag starts, keeping its edges hidden until a parent resync; the live-store update and cancellation regression need to clear and verify that flag.

1 open issue
What changed in this PR

Addresses #36362 by keeping active node drags inside React Flow, avoiding the controlled-state update loop that can crash lineage canvases during edge auto-pan.

Changes:

  • Adds a shared drag hook and integrates it into both lineage canvases, preserving in-flight positions across parent renders and committing positions on drop.
  • Hides dragged nodes’ edges from rendering and hit-testing while keeping other edges visible.
  • Adds regression coverage, Playwright impact mappings, and a decision record documenting drag ownership.
File Description
openmetadata-ui/​src/​main/​resources/​ui/​src/​utils/​EdgeMidpointUtils.ts Excludes dragged-node edges from midpoint markers.
openmetadata-ui/​src/​main/​resources/​ui/​src/​utils/​EdgeMidpointUtils.test.ts Tests dragged-node edge detection.
openmetadata-ui/​src/​main/​resources/​ui/​src/​hooks/​useCanvasEdgeRenderer.ts Filters dragged-node edges from canvas rendering.
openmetadata-ui/​src/​main/​resources/​ui/​src/​hooks/​useCanvasEdgeRenderer.test.ts Verifies unrelated edges remain drawn.
openmetadata-ui/​src/​main/​resources/​ui/​src/​hooks/​lineage/​useUncontrolledNodeDrag.ts Keeps drag frames local and commits drop positions.
openmetadata-ui/​src/​main/​resources/​ui/​src/​hooks/​lineage/​useUncontrolledNodeDrag.test.tsx Covers drag updates, overlays, cancellation, and passthrough.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Lineage/​UncontrolledDragFlow/​UncontrolledDragFlow.tsx Integrates the hook within the existing flow provider.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Lineage/​UncontrolledDragFlow/​UncontrolledDragFlow.test.tsx Exercises drag handling through the real flow store.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Lineage/​LineageMap/​LineageMap.component.tsx Applies uncontrolled dragging to the platform map.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Lineage/​EntityLineageCanvas/​EntityLineageCanvas.tsx Uses the drag-aware React Flow wrapper.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Lineage/​EntityLineageCanvas/​EntityLineageCanvas.test.tsx Adapts the canvas mock to the wrapper.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Entity/​EntityLineage/​CanvasEdgeRenderer.component.tsx Refreshes test markers from live flow nodes.
openmetadata-ui/​src/​main/​resources/​ui/​src/​components/​Entity/​EntityLineage/​CanvasEdgeRenderer.component.test.tsx Adds the live-node hook mock.
openmetadata-ui/​src/​main/​resources/​ui/​playwright/​e2e/​Pages/​Lineage/​LineageControls.spec.ts Adds auto-pan, edge visibility, and drop-position regression checks.
docs/​decisions/​2026-11-03-lineage-node-drags-stay-in-react-flow-until-drop.md Records drag ownership and edge visibility contracts.
.github/​playwright/​impact-map.json Maps drag and edge utilities to lineage tests.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 1 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 1 warning(s) across 1 changed file(s).

Count Rule
1 react-hooks/exhaustive-deps
All findings
Location Rule Message
🟡 src/components/Lineage/EntityLineageCanvas/EntityLineageCanvas.tsx:133:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'updateEntityData'. Either include it or remove the dependency array.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
80.94% (136977/169216) 67.84% (49147/72441) 70.9% (27679/39036)

… drag starts

A touch drag cancelled by a second finger sends no drop. Forgetting it on the
next drag left React Flow's store marking that node as dragging, so its edges
stayed hidden until a parent re-sync, and its last position never reached the
caller. Such a drag is now settled as a drop: its dragging flag is cleared in
React Flow's store and its last position is reported once.
The redraw effect cancelled its scheduled frame on every dependency change
and rescheduled it. React Flow's auto-pan moves the viewport from its own
animation frame, which runs just before ours, so every frame cancelled the
draw and the edge canvas froze until the drop. A scheduled frame now
survives dependency changes (it reads the latest state through a ref) and
is cancelled only on unmount.
Copilot AI balanced review requested due to automatic review settings November 3, 2026 08:56
@gitar-bot

gitar-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Changes lineage drag-state handling and edge rendering; incorrect position commits or edge visibility could disrupt users editing lineage graphs.

Makes lineage node drags uncontrolled until the drop via a new useUncontrolledNodeDrag hook and UncontrolledDragFlow wrapper, so holding a dragged node at the canvas edge no longer triggers "Maximum update depth exceeded". Only the dragged node's edges hide during the drag, and the edge canvas keeps repainting during auto-pan. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues require resolution for the lineage drag-handling change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@Rohit0301
Rohit0301 added this pull request to the merge queue Nov 3, 2026
@chirag-madlani
chirag-madlani merged commit dc25c14 into main Nov 3, 2026
76 of 77 checks passed
@chirag-madlani
chirag-madlani deleted the chirag-madlani/lineage-uncontrolled-drag branch November 3, 2026 18:16
mohityadav766 added a commit that referenced this pull request Nov 4, 2026
…age-release-fixes

#36901 drives the lineage map's nodes through useUncontrolledNodeDrag; the
canvas keeps its lineage-map-canvas wrapper around the new flow props.
#35438 gave the Lineage page's settings button a translated tooltip, so the
action-button memo depends on t again. The Playwright impact map is
regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lineage: node drag held at the canvas edge can crash with 'Maximum update depth exceeded' (make drag uncontrolled)

3 participants