Skip to content

Break out element display and click handlers into hooks#73332

Merged
bencodeorg merged 1 commit into
stagingfrom
ben/break-up-react-flow-canvas
Jun 18, 2026
Merged

Break out element display and click handlers into hooks#73332
bencodeorg merged 1 commit into
stagingfrom
ben/break-up-react-flow-canvas

Conversation

@bencodeorg

@bencodeorg bencodeorg commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Pulls out a couple of large blocks of code into hooks from ReactFlowCanvas, which was getting unwieldy. One for click handlers and related pieces (node click, edge click, etc.), and one for memoized calculation of nodes and edges to display.

Follow-up to a comment in this PR: #73182 (comment)

Testing story

Tested manually that dragging/grouping/rendering of nodes/edges appeared to continue to function as expected.

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.

Pull request overview

Refactors Sketchlab React Flow canvas logic by extracting element click/selection handling and display element derivation into dedicated hooks, reducing ReactFlowCanvas size and centralizing related behavior.

Changes:

  • Added useElementClickHandlers to encapsulate node/edge click handling, multi-selection state, and selection clearing.
  • Added useDisplayElements to memoize and compute displayNodes/displayEdges (selection state, accessibility attributes, reconnectability, and styling).
  • Updated ReactFlowCanvas to consume these hooks and removed the inlined logic.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
apps/src/sketchlab/reactFlow/hooks/useElementClickHandlers.ts New hook for node/edge click behavior and multi-selection state management.
apps/src/sketchlab/reactFlow/hooks/useDisplayElements.ts New hook encapsulating memoized computation of rendered nodes/edges (selection, a11y, styling, reconnectability).
apps/src/sketchlab/reactFlow/components/ReactFlowCanvas.tsx Replaces large inlined blocks with the new hooks to simplify the canvas component.

@bencodeorg bencodeorg requested a review from a team June 18, 2026 18:56

@molly-moen molly-moen 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.

🎉

@bencodeorg bencodeorg merged commit db271dd into staging Jun 18, 2026
9 checks passed
@bencodeorg bencodeorg deleted the ben/break-up-react-flow-canvas branch June 18, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants