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: undo/redo for auto disabling if-return blocks #6018

Merged
merged 2 commits into from
Mar 23, 2022

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

#6010

Proposed Changes

Wrap the enable/disable event for the if-return in the same group as the initial move event, so the events get undone together. This is the same way the break/continue block handles this behavior.

Behavior Before Change

Undoing was not possible because the events were not properly grouped.

Behavior After Change

Now the events are properly grouped so undo and redo works.

Reason for Changes

Undo and redo are helpful.

Test Coverage

  1. Drag an if-return from the workspace to a procedure. Undo and redo.
  2. Drag an if-return from the workspace to a block inside a procedure. Undo and redo.
  3. Drag an if-return from the workspace to a disabled block inside a procedure. Undo and redo. Enable the disabled block. Observe how the if-return is enabled.
  4. Drag an if-return from a procedure to the workspace. Undo and redo.
  5. Drag an if-return from a procedure to a block on the workspace. Undo and redo.
  6. Drag an if-return from a procedure to a disabled block on the workspace. Undo and redo. Enable the disabled block. Observe how the if-return is not enabled.

Tested on:

  • Desktop Chrome

Documentation

Additional Information

N/A

@BeksOmega BeksOmega requested a review from a team as a code owner March 22, 2022 16:47
@BeksOmega BeksOmega requested a review from alschmiedt March 22, 2022 16:47
@@ -1139,11 +1139,12 @@ blocks['procedures_ifreturn'] = {
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!AbstractEvent} _e Change event.
* @param {!AbstractEvent} e Change event.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update this to be "Move event"?

this.setEnabled(false);
}
}
if (!this.isInFlyout) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why don't we need the this.getInheritedDisabled anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we ever needed it. That would mean that if you dragged an if-return out of a procedure block, and into a disabled block, it wouldn't get disabled itself. Then you could re-enable the disabled parent, and the if-return would get enabled as well, which is not the behavior we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants