Changes in field validators aren't grouped with field changes. #8588
Labels
issue: bug
Describes why the code or behaviour is wrong
issue: triage
Issues awaiting triage by a Blockly team member
Check for duplicates
Description
In #8575 I noticed that the undo history isn't recorded correctly when a block's inputs are created or destroyed in response to a field validator. If a child block was attached to an input when the input is being destroyed, the block will become detached, which is recorded as a
BlockMove
event, but this event is not grouped with theBlockChange
that caused it. This can cause problems when undoing, because the creating the input separately from moving the detached child block is likely to "bump" the child otherwise. If the child block gets bumped while undoing, that records a BlockMove event that can unintentionally erase any remaining the redo history.The following block types are known to be affected:
lists_getIndex
lists_setIndex
lists_getSublist
text_getSubstring
Whether or not we want people to be making changes to the workspace in field validators is an interesting question, but the fact remains that it's already happening, in the blockly core library no less.
See also: #6456
Reproduction steps
lists_getIndex
and amath_number
block into the workspace.lists_getIndex
block. A BlockMove event with a group id will have been fired, followed by a BlockChange event without any group id.Screenshots
Screen.Recording.2024-09-24.at.12.04.43.PM.mov
The text was updated successfully, but these errors were encountered: