Skip to content

feat: Add mouse right-button + drag box selection for lineage graph - #588

Open
seohyunjun wants to merge 2 commits into
dbt-labs:mainfrom
seohyunjun:feat/add-drag-box
Open

seohyunjun wants to merge 2 commits into
dbt-labs:mainfrom
seohyunjun:feat/add-drag-box

Conversation

@seohyunjun

@seohyunjun seohyunjun commented Oct 4, 2026 •

Copy link
Copy Markdown

resolves #86

Description

Adds right-button drag box selection to the lineage graph (DAG view).

In the current graph, boxSelectionEnabled: false makes a left drag pan the view, so there's no way to select several nodes at once and move them together (#86). This PR keeps panning as it is and gives box selection to the right button instead.

drag-motion.mov

How it works

Action Result
Right-drag Draws a dashed box. On release, every visible node the box touches is selected (any existing selection is replaced).
Shift + right-drag Adds the nodes to the existing selection.
Left-drag on a selected node Moves the whole selection (cytoscape's default behavior).
Right-click without dragging Opens the node context menu as before.

Implementation

  • src/app/components/graph/graph-box-select.js (new)
    • Uses cytoscape's cxttapstart / cxtdrag / cxttapend events to draw the box and run hit-testing.
    • The box is an absolutely positioned div inside the cytoscape container (pointer-events: none), so it doesn't interfere with canvas events.
    • Hit-testing compares each node's renderedBoundingBox({ includeLabels: false }) against the box. Hidden nodes are skipped.
    • Boxes smaller than 4px are ignored so small mouse movements don't trigger a selection.
    • Selection changes run inside cy.batch() so they render only once.
  • src/app/components/graph/graph-viz.js: calls enableRightDragBoxSelect(cy) after the graph is created.
  • src/app/components/graph/graph-viz.css: adds the .graph-box-select style for the box (#bd6bb6 dashed border with a translucent fill).
  • src/app/services/graph.service.js: adds a node:selected style (purple border and overlay).
    • This is cytoscape's own selection state. It's separate from the app's existing selected=1 lineage highlight for the clicked node.
    • The rule is placed last in the stylesheet so it wins over the per-resource-type border colors.
  • .changes/unreleased/Docs-20261004-220000.yaml: changelog entry.

No conflict with the context menu

cytoscape-context-menus listens to cxttap, which cytoscape fires only for a right click without a drag. A right-drag never opens the menu, and a right-click still does.

Tradeoffs / notes

  • I kept cytoscape's built-in boxSelectionEnabled (shift + left-drag) off. Turning it on would conflict with the existing left-drag panning UX.
  • The selection is visual and interactive only. It doesn't change the lineage selector (--select) or the URL state.

Checklist

🤖 Generated with Claude Code

@seohyunjun
seohyunjun requested a review from a team as a code owner October 4, 2026 12:47
@cla-bot

cla-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, please reach out through a comment on this PR.

CLA has not been signed by users: @seohyunjun

@seohyunjun

Copy link
Copy Markdown
Author

I’ve completed and submitted the Individual Contributor License Agreement (CLA). Please let me know if there’s anything else I need to do. Thanks!

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select multiple nodes on data lineage graph

1 participant