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: proc call remain disabled as def changes name #2043

Conversation

alicialics
Copy link
Contributor

The basics

The details

Resolves

Fixes #2035

Proposed Changes

When a proc call changes enabled state independently, previousEnabledState_ should be kept in sync

Reason for Changes

#2035

Test Coverage

The unit test requires a setGroup call in order to simulate what happens in UI (ie when a proc call gets disabled)

Documentation

Additional Information

@BeksOmega I am not familiar with groups. I checked that when a proc call gets disabled in the UI it has a group name but when it is disabled as part of proc def block update it does not have a group name. So I might be totally wrong here =)

@alicialics alicialics requested a review from a team as a code owner October 27, 2023 04:40
@alicialics alicialics requested review from BeksOmega and removed request for a team October 27, 2023 04:40
Copy link
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

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

This seems to also be broken on load. (e.g. deserializing a disabled caller with an enabled def enables the caller) Could you figure out what's up with that and then I'll re-review?

If you're busy or that's too much load also totally cool! Just lmk!

event.type === Blockly.Events.BLOCK_CHANGE &&
event.blockId === this.id &&
event.element === 'disabled' &&
event.group
Copy link
Contributor

Choose a reason for hiding this comment

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

Groups are for handling undo and redo, so you shouldn't need to check for this explicitly! We don't care if it's being bundled with other events for undo/redo :P

You should also be able to remove it from your unit test.

Copy link
Contributor Author

@alicialics alicialics Oct 27, 2023

Choose a reason for hiding this comment

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

Gotcha! makes sense.

Unfortunately if I remove event.group the patch won't work. This is because if you disable a proc def it will trigger a proc call enable/disable call and I have no idea how to distinguish it with disabling it directly. Adding event.group in the UI seem to work but it doesn't feel like the right fix so I will close this PR for now. =)

event.element === 'disabled' &&
event.group
) {
this.previousEnabledState_ = !event.newValue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is equivalent but I think it's a little clearer.

Suggested change
this.previousEnabledState_ = !event.newValue;
this.previousEnabledState_ = event.oldValue;

Copy link
Contributor

Choose a reason for hiding this comment

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

Wanted to come back here and say that as I was rewriting this, you're right that !event.newValue is the correct way to do this :P

@alicialics alicialics closed this Oct 27, 2023
@alicialics alicialics deleted the fix_procedure_block_disabled_state branch October 27, 2023 19:26
@BeksOmega
Copy link
Contributor

Hmm did you try checking for recordUndo instead of group? If undo is enabled on the direct call to the procedure caller, it shouldn't be, and we should fix that. Then you should be able to differentiate a user-made change vs a programmatic change.

@alicialics
Copy link
Contributor Author

alicialics commented Oct 28, 2023

@BeksOmega I double checked the events being outputted in these instances and the only difference I see is event.group is empty vs not. =(

Then you should be able to differentiate a user-made change vs a programmatic change.

Totally agree, this is a little bit out of my league however so I'll leave it to the blockly team

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.

Disabled procedure blocks are re-enabled after a change
2 participants