-
-
Notifications
You must be signed in to change notification settings - Fork 666
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
fix: use fixed event listeners to address race conditions #1566
base: experimental
Are you sure you want to change the base?
fix: use fixed event listeners to address race conditions #1566
Conversation
🦋 Changeset detectedLatest commit: fc86a6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
for (const draggable of this.manager.registry.draggables.value) { | ||
if (draggable.element) { | ||
documents.add(getDocument(draggable.element)); | ||
} | ||
} | ||
|
||
for (const droppable of this.manager.registry.droppables.value) { | ||
if (droppable.element) { | ||
documents.add(getDocument(droppable.element)); | ||
} | ||
} | ||
|
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.
Noting that this may be better elsewhere for perf reasons
// Event may have duplicated between documents if user is bubbling events | ||
if (doc !== ownerDocument) { | ||
return; | ||
} |
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.
Note, new safe-guard to account for an edge-case where the user bubbles the pointermove
event to the parent document (as I am doing with Puck).
I can address this on my end, but a safe-guard seemed sensible.
Refactor the PointerSensor to use fixed event listeners, rather than dynamic ones, preventing race conditions that can occur if the document changed during drag, such as when dragging across frames.
To reproduce, rapidly drag items from the host to the iframe in the iframe stories.