scratchfoundation / scratchfoundation/scratch-editor

Bug when dragging overlapping sprites

Open
#378 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
281
Forks
276
Avg merge
7d 8h
Merged PRs (30d)
6

Description

https://scratch.mit.edu/discuss/topic/847056/

Expected Behavior

The topmost sprite is picked up

Actual Behavior

Depending on the dragging speed, different things can happen:

  • the wrong sprite is picked up
  • the right sprite is picked up, but the other sprite is hidden and it's motion blocks are disabled
Steps to Reproduce

Place two sprites such that they are overlapping and the first sprite from the sprite list is on top of the second sprite. Try dragging the first sprite where it covers the second sprite.

If you click and wait until the sprite is automatically picked up, then it usually picks up the second sprite.
If you press the mouse button while the mouse is already moving then it usually hides the second sprite and picks up the first one

Steps to reproduce the behavior:

  1. Go to 'https://scratch.mit.edu/projects/editor/'
  2. Add a sprite (eg. 'Bear')
  3. Drag and drop the Scratch Cat on the Bear
  4. Try dragging the Scratch Cat where it covers the Bear
System Details

Windows 10, Chrome 132

Screenshots

https://github.com/user-attachments/assets/3ce44dfc-570b-44f4-ba30-d1f943f552a6

I've looked into the code and in stage.jsx#L345-L364 the draggable targets are tested in the order they appear in vm.runtime.targets, which is not the layer order

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the overlap-dragging case in the Scratch editor, then read packages/scratch-gui/src/containers/stage.jsx around lines 345-364 and inspect how vm.runtime.targets are checked. Done means dragging the topmost overlapping sprite consistently selects it without hiding the other sprite or disabling its motion blocks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.