Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workspace shifts when deleting a block #8666

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

mateusslezinsky
Copy link

The basics

The details

Resolves

Workspace shifts when deleting a block

Proposed Changes

Instead of resizing the workspace everytime a drag is finished, resizes when a block is deleted.

Reason for Changes

To fix issue #8655.

Test Coverage

Before changes:
before_changes.webm

After changes:
after_changes.webm

@mateusslezinsky mateusslezinsky requested a review from a team as a code owner November 18, 2024 20:47
@github-actions github-actions bot added the PR: fix Fixes a bug label Nov 18, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome! It looks like this is your first pull request in Blockly, so here are a couple of tips:

  • You can find tips about contributing to Blockly and how to validate your changes on our developer site.
  • All contributors must sign the Google Contributor License Agreement (CLA). If the google-cla bot leaves a comment on this PR, make sure you follow the instructions.
  • We use conventional commits to make versioning the package easier. Make sure your commit message is in the proper format or learn how to fix it.
  • If any of the other checks on this PR fail, you can click on them to learn why. It might be that your change caused a test failure, or that you need to double-check the style guide.
    Thank you for opening this PR! A member of the Blockly team will review it soon.

@gonfunko
Copy link
Contributor

Hi, thank you for your interest and resolving this issue and for putting together this PR! While I see from your videos it stops the workspace movement, I think the original call to setResizesEnabled() is still necessary, because it pairs with the corresponding call in startDrag() to reenable workspace resizing after startDrag() disables it for the duration of the drag. In cases where the drag does not result in deletion, resizing would never be reenabled with this change. If you're interested in investigating further, I'd investigate the calls to snapToGrid() and queueRender(); my suspicion is there may be a race condition with block deletion and the things (like snapping and rerendering) we'd do at the end of a normal non-deletion drag which are unnecessary if the block is being deleted but desirable (and could potentially result in adjusting the workspace bounds) in the case where a block is just being moved.

@mateusslezinsky
Copy link
Author

mateusslezinsky commented Nov 27, 2024

Hi, thank you for your interest and resolving this issue and for putting together this PR! While I see from your videos it stops the workspace movement, I think the original call to setResizesEnabled() is still necessary, because it pairs with the corresponding call in startDrag() to reenable workspace resizing after startDrag() disables it for the duration of the drag. In cases where the drag does not result in deletion, resizing would never be reenabled with this change. If you're interested in investigating further, I'd investigate the calls to snapToGrid() and queueRender(); my suspicion is there may be a race condition with block deletion and the things (like snapping and rerendering) we'd do at the end of a normal non-deletion drag which are unnecessary if the block is being deleted but desirable (and could potentially result in adjusting the workspace bounds) in the case where a block is just being moved.

Hello! I have been debugging this issue and it indeed looks like a race condition. The reason for this is because this.block.queueRender() returns a Promise, which is async.

Marking endDrag method from block_drag_strategy as async and then inserting await to queueRender (as await this.block.queueRender()) does fixes the issue however. Should I choose this approach or attempt other fix?

@mateusslezinsky
Copy link
Author

After the latest changes, here is how it looks like:
latest.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants