-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix dragging within multiple editors #6543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@@ -151,9 +151,6 @@ export function useCanvasEvents() { | |||
let lastX: number, lastY: number | |||
|
|||
function onPointerMove(e: PointerEvent) { | |||
if ((e as any).isKilled) return | |||
;(e as any).isKilled = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was added in the drag out of toolbar PR. @SomeHats did this prevent some issues with that feature? Can we safely remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure - i think @steveruizok added this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks like the early return was there before, but the killing of the event was added in that PR https://github.com/tldraw/tldraw/pull/6563/files#diff-980beb0aa0ee9aa6d1cd386cef3dc05a500c030638ffb58d45fd11b79126103fL48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this to avoid loops when events are re-dispatched to the canvas, or when events would bubble through shapes. I don't think we rely on this as much since moving away from DOM based hit testing in 2023.
Reverts #6543 This was causing events to get dispatched multiple times (maybe 3???), resulting in v janky drawing: <img width="1731" height="739" alt="image" src="https://github.com/user-attachments/assets/16e56cb9-f42f-4ec8-b9ee-f3abd971892d" />
This PR fixes dragging interactions when using multiple tldraw components on the same page. eg: Inset editors with fixed sizes and Common practices with inset editors
The bug happened because we're now handling pointer move events on a document basis, not an editor-by-editor basis. This meant that different tldraw editors were killing the pointer move event, preventing other editors from handling it.
This PR fixes the bug by no longer killing the event. If we do need to kill the event, perhaps we could kill the event on an editor-by-editor basis by tracking this as a map instead of a boolean or something.
Change type
bugfix
improvement
feature
api
other
Test plan