-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
field_label modified in dynamic category resets when dragged onto workspace #1954
Comments
Which block reverts to "undefined"? The one in the flyout or the copy that has been dragged out? I'm guessing you mean the latter. Field labels are not serialized, so they value you assign is not preserved during save/load, including the copy process during dragging from the toolbox. If you want to preserve/serialize this data, you will need to add mutator functions Web Blockly mutators are covered here. |
Right, fields have an EDITABLE property that is false on labels. It controls whether they are serialized. In scratch-blocks we added a new type of field called field_label_serializable that does what you want, but that also required changes in the base field class. In the short term, domToMutation and mutationToDom are probably easier. |
If I modify a label in a dynamic catetory, it resets when I drag it onto the workspace.
Given a block with a label like this:
And a dynamic category with a block like:
The flyout correctly shows the dynamically set label value.
But the moment I drag the block from the flyout onto the workspace, it resets to
undefined
.If I change the block type to
field_input
, it works fine. This is undesirable though, as I don't want it to appear as an input field, it's a dynamic part of the block description that I'm trying to change whenever the flyout is opened.The only workaround I've found is to use a change listener to override the field value.
The text was updated successfully, but these errors were encountered: