fix: Group field validator changes with field value changes. #8589
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 #8588
Also fixes #6456
Proposed Changes
Creates a change group before performing any field validation, and uses this group for the field value change event.
Reason for Changes
There are field validators in the core blockly library that make workspace changes in response to field value changes. For example, the block
list_getIndex
creates or destroys an input connection depending on the value of a dropdown. However, these changes do not get grouped with the field value changes, which causes problems when undoing.This PR also allows change listeners to retroactively create changes that are grouped with the changes that they are responding to, which is a technique that is already used by some plugins but is incompatible with fields that don't assign any group id to their value changes.
Test Coverage
All existing tests pass, except for the 4
WorkspaceSvg cleanUp
test methods that are already currently broken in thedevelop
branch. (Are these known? I'm testing on a Mac and some coordinates are slightly off.)