fix(select): allow dragging shapes that have an onClick handler#7936
fix(select): allow dragging shapes that have an onClick handler#7936steveruizok merged 6 commits intomainfrom
Conversation
When a shape has an onClick handler and is not selected, PointingShape defers selection to pointer up. But if the user drags instead, the Translating state requires a selection and bails out to idle. Fix by selecting the shape in startTranslating when nothing is selected. Closes #5613
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
Adds an example demonstrating ShapeUtil.onClick on a custom shape, making it easy to verify that clicking increments a counter while dragging still translates the shape correctly. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
I'm observing something that looks weird, after dragging I can see the handles, trying to resize will "drag along", Is this a regression? dragandresizewithonclick.mov |
mimecuvalo
left a comment
There was a problem hiding this comment.
oh actually i take it back - i didn't see @kaneel found a regression - let's look at that pls!
This is just because the shape doesn't implement an onResize, unrelated to this PR. I'll make it extend baseboxutil though. |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
image-pipeline-template | 978e355 | Mar 02 2026, 08:45 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
multiplayer-template | 978e355 | Mar 02 2026, 08:45 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
agent-template | 978e355 | Mar 02 2026, 08:45 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
agent-template | 978e355 | Mar 02 2026, 08:48 AM |
…lder The example declared `category: shapes/tools` but was placed at the top level, causing the Vite build to fail with "Example category folder missing". Co-Authored-By: Claude Opus 4.6 <[email protected]>
Closes #5613
When a custom shape has an
onClickhandler and is not yet selected,PointingShape.onEnterdefers selection to pointer up (so thatonClickcan fire). However, if the user drags instead of clicking, theTranslatingstate requires a selection to operate and immediately bails back to idle—making it impossible to drag unselected shapes that have anonClickhandler.This PR fixes the issue by selecting the shape in
startTranslatingwhen the shape wasn't selected on enter and there is no existing selection. This ensures that dragging works correctly while preserving the existing behavior for shapes that are already selected or part of a multi-selection.Kapture.2026-02-15.at.00.28.55.mp4
Change type
bugfixTest plan
onClickhandleronClickhandler should still fireRelease notes
onClickhandler.Note
Medium Risk
Touches the
SelectToolstate machine to change when selection is applied during a drag, which could subtly affect selection/translation behavior in edge cases (e.g. grouped or multi-selected shapes). Covered by a new unit test, but still impacts core interaction logic.Overview
Fixes a selection/translation edge case where shapes with a
ShapeUtil.onClickhandler could not be dragged while unselected.PointingShape.startTranslatingnow ensures the hit shape is selected (only when it wasn’t selected on enter and there’s no existing selection) before transitioning to translating, preserving click-to-run-onClickbehavior.Adds a regression unit test for dragging shapes with
onClick, and introduces a new examples page (shape-with-onClick) demonstrating a clickable custom shape that increments a counter viaShapeUtil.onClick.Written by Cursor Bugbot for commit c7f6206. This will update automatically on new commits. Configure here.