Fix/collapse expand arrow drag #5399
Open
+58
−30
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.
isssue : #5361
Problem:
In the Music Blocks editor, the collapse/expand arrow on Note blocks behaves unreliably.
Clicking the arrow sometimes initiates a drag action instead of toggling the collapsed state, causing the Note block to detach from its parent (e.g., Start or Set Instrument block).
This makes collapsing/expanding notes frustrating and unpredictable for users.
Root Cause:
The issue was caused by conflicting event handlers in block.js:
-mousedown correctly detects clicks on the collapse/expand arrow, but does not prevent drag initialization
-pressmove always starts dragging on even tiny mouse movements
->As a result, small pointer movement between mousedown and click triggers drag before the collapse action can occur
Solution:
This PR introduces a small but robust fix to clearly separate collapse intent from drag intent:
-Track when the collapse/expand arrow is clicked using a dedicated flag
-Prevent drag logic from running when the interaction starts on the arrow
-Reset the flag safely on pressup and mouseout events
This ensures:
->Clicking the arrow always toggles collapse/expand
->Dragging only occurs when interacting with the block body
->No regression to normal drag behavior
Testing Performed:
Manual testing in browser:
-Created a project with a Start block and a nested Note block
-Clicked the collapse/expand arrow rapidly multiple times
Block toggles correctly every time
Block never detaches from parent
Dragged the Note block from its body (not the arrow)
Drag behavior works as expected
Visual Proof:
-Before: Clicking the collapse arrow sometimes drags the block out
-After: Collapse/expand works reliably with no accidental dragging
(Attached before/after screenshots for reference)
Files Changed:
->block.js
Notes:
I’m happy to make adjustments if maintainers prefer a different approach.