fix(dom/events): ensure mouseReleased fires after DOM interactions#8366
Open
sidhansu10 wants to merge 1 commit intoprocessing:mainfrom
Open
fix(dom/events): ensure mouseReleased fires after DOM interactions#8366sidhansu10 wants to merge 1 commit intoprocessing:mainfrom
sidhansu10 wants to merge 1 commit intoprocessing:mainfrom
Conversation
17 tasks
davepagurek
reviewed
Dec 31, 2025
| node.appendChild(elt); | ||
| elt.addEventListener('mouseup', e => { | ||
| if (pInst && pInst.mouseIsPressed && typeof pInst._onmouseup === 'function') { | ||
| pInst._onmouseup(e); |
Contributor
There was a problem hiding this comment.
For non-Safari and for non-select elements, would this cause the event to be dispatched twice?
Author
There was a problem hiding this comment.
The guard on mouseIsPressed should prevent double dispatch in browsers where mouseup already propagates correctly. If the canvas mouseup has already fired, mouseIsPressed will be false, so _onmouseup won’t be called again. This mainly addresses Safari, where mouseup often doesn’t reach the canvas after DOM interactions, leaving mouseIsPressed stuck true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where interacting with p5 DOM elements (e.g.
createSelect)in Safari triggers
mousePressedbut notmouseReleased, leavingmouseIsPressedstuck in a true state.Details
mouseupback to the canvas after DOM interactionsmouseupevents to p5’s internal mouse handlermouseIsPressedis trueaddElementto cover all p5 DOM elementsResolves #8293