fix: Mitigate shareable procedure flyout bug. #2493
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #2484
Proposed Changes
Prevents deletion of a procedure call block inside a flyout in response to deleting the associated definition.
Reason for Changes
There's a bug where call blocks in flyouts get disposed twice, and the second time results in an error getting thrown that prevents opening the flyout.
Flyouts do not get immediately rerendered or updated in response to a block being deleted. However, when opening a flyout, they do dispose any blocks that they already own before re-rendering themselves. If one of these blocks was already disposed, it'll get disposed a second time (which fails). This PR prevents the block from getting disposed the first time, so that the flyout can successfully clear itself.
It might seem like a problem that a flyout that is open can continue to contain a call block for a procedure that doesn't exist anymore. However, if this call block is dragged to the workspace, the procedure definition will reappear.
This is the same workaround implemented by code.org in: code-dot-org/code-dot-org#63662
Alternatively, we could investigate properly re-rendering the flyout in response to changes in its workspace, but that might involve changes to core blockly?
Test Coverage
I tested manually.
Documentation
N/A
Additional Information
N/A