Scratch-gui: Blocks getting deleted when not over the flyout

Created on 15 Dec 2017  路  8Comments  路  Source: LLK/scratch-gui

Expected Behavior

The stack should move, not get deleted

Actual Behavior

Notice I'm scrolled over to the right in Chrome.
I move the stack of blocks and it gets deleted.

Steps to Reproduce

accidentaldelete

Operating System and Browser

Windows 10 Chrome

bug help wanted

Most helpful comment

@paulkaplan Adding to "Bugapalooza"

All 8 comments

@fsih can you repro this consistently?

@paulkaplan Yes. I needed a couple more steps.

  1. Have the browser window be narrow enough that you have a horizontal scroll
  2. When the scroll is all the way to the left, drag a block to the workspace
  3. Scroll all the way to the right.
  4. Drag the block. The delete cursor shows up when you're over the left side of the workspace.

I found a related case:

  1. On a fresh workspace (without dragging any blocks anywhere), scroll right
  2. Drag any block anywhere
  3. Scroll back to the left. Now the threshold for where blocks get deleted is too far to the left.
    dragbug2

@paulkaplan Adding to "Bugapalooza"

@thisandagain say what now??

Note: this only happens when the GUI is being used in a window that is below our minimum resolution and is then scrolled or resized.

Looks like a Scratch-Blocks problem with calculation of delete areas (not taking into account window offsets).

Which probably means that somewhere there's a missing call to Blockly.WorkspaceSvg.prototype.updateScreenCalculationsIfScrolled()

Blockly caches the delete areas instead of calculating them every time it checks for a deletion. The delete area for the toolbox and flyout is calculated with getClientRect. That calls getBoundingClientRect on an SVG group, which does take into account the scroll position, so you just need to make sure it's called again when scrolls happen.

I see an expected call at the beginning of a gesture here: https://github.com/LLK/scratch-blocks/blob/develop/core/gesture.js#L427
That should mean that when a block drag is started, we check to see if the page has scrolled since the last time. If so, it should re-calculate. I don't have a clean enough debug branch to check whether we're getting inside this if statement to verify though

Was this page helpful?
0 / 5 - 0 ratings