question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selected block not cleared after dragging a block

See original GitHub issue

Expected Behavior

After dragging a block (either from the flyout or on the workspace), the ‘selected’ block (Blockly.selected) should be cleared. This means that clearing the ‘selected’ block should be done on mouse up. Using this, every time a block is picked up on, an ‘ui’ event is created and can be acted upon.

Actual Behavior

After dragging a block, the ‘selected’ block is not cleared. The value of Blockly.selected is still the last block dragged, until a new block is selected or a mouse down event happens. Currently, since the ‘selected’ block is not cleared, when dragging a block for the 2nd time in a row (without interacting with anything else in the meantime), no ‘ui’ event is created, and so it is not as easy as it should to detect that this block was picked up.

Steps to Reproduce

  1. Launch tests/vertical_playground.html in your browser
  2. Enable Log Events option
  3. Drag a block from the flyout to the workspace
  4. Notice that 3 events are logged: “Create” (when the dragged block is created); “Ui” (when this new block is selected); “Move” (when the block is set on the workspace)
  5. Without clicking anywhere else first, drag the block again from the workspace to some other position on the workspace
  6. Notice that only a “Move” event is logged, while we would except a “Ui” event first

Operating System and Browser

Mac OS 10.11.6 Chrome 58.0.3029.110 (64-bit)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rachel-fenichelcommented, May 25, 2017

It’s the same behaviour as you get when you drag files around on your desktop or in a file explorer generally. Clicking on an item selects it and it stays selected until something else is selected or the selection is explicitly removed (by clicking on the background, for instance). Dragging does the same thing.

I’m not sure what to say about the conceptual strangeness–to me it feels completely natural, and to you it obviously doesn’t. Maybe some programs implement it one way and the others implement it the other, so there’s no default behaviour?

I don’t strongly object to scratch-blocks changing it, I just wanted it to be clear that this isn’t an accidental regression.

I don’t think the code relies on the previous block being selected or not, so your patch should be fine.

0reactions
MichaelZawadzkicommented, May 30, 2017

Thanks for the explanation!

I had to play with my desktop for a second but I totally see what you mean, and indeed in this context it makes perfect sense 😉

In scratch + scratch-blocks once the block is released there is no special visual indication that it is still selected. This makes sense since there is no special action you can take on it (while on your desktop some hotkeys can allow you to rename this selected file). So this notion of “selected” is not really present for the user in scratch. Thanks for confirming that the code doesn’t rely on this “selection” for anything. Indeed we haven’t seen any problems with it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to drag and drop blocks - WordPress.org
Now that I've updated my site to WordPress 5.4, I am unable to select a given block and manually drag it to another...
Read more >
Blockly, detect connection/removal/dragging/releasing a block
Block connections fall under MOVE. Check for an empty workspace after each DELETE. I don't think we have an event for the start...
Read more >
Block Options - Qualtrics
Your questions will now be placed in a new block at the bottom of your survey. To move your block elsewhere, drag and...
Read more >
Add, arrange, or delete blocks in your email template
Each block has its own toolbar to make specific edits based on the type of block. All blocks can be deleted using the...
Read more >
Sections and blocks - Shopify Help Center
You can further customize the section by editing its Settings to include an image and choose the alignment, size, background color, and what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found