Skip to content

[Upstream] preserve dropdown values #226

@SimonShiki

Description

@SimonShiki

Description

Scratch dynamically constructs its sprite-targeting dropdowns (e.g., motion_goto_menu, motion_pointtowards_menu, sensing_touchingobject_menu) from the active project's sprite roster at runtime, intentionally filtering out the sprite currently under edit. Consequently, when a user duplicates a block from a different sprite into the current one, the serialized field value may reference an entry absent from the destination's filtered dropdown options.

Current Behavior

Blockly's standard FieldDropdown validator discards unrecognized values during deserialization. This forces an implicit rollback to the dropdown's first enumerated choice, creating a display-execution divergence: the editor renders the default selection while scratch-vm continues executing against the original, persisted value.

Recommended strategy from upstream

Extend ScratchFieldDropdown with two method overrides:
doClassValidation_: Permit any string input unconditionally, bypassing the restrictive default validation.
getText_: Implement a fallback mechanism—when the stored value lacks a corresponding option entry, display the raw string literal; otherwise, defer to the superclass implementation to preserve correct rendering of complex option types (images and HTMLElements).

Metadata

Metadata

Assignees

Labels

P2Medium priority to doblockThings related to clipcc-block.upstreamThe content is related to upstream.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions