-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
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:
blocks["event_rule"] = {
init: function() {
this.jsonInit({
message0: "%1 events",
message1: "Rules: %1",
args0: [
{
type: "field_label",
name: "eventName"
}
],
.....
And a dynamic category with a block like:
const blocks = [
`
<block type="event_rule">
<field name="eventName">${activeEvent}</field>
</block>
`
];
return blocks.map(block => `<xml>${block}</xml>`).map(block => Blockly.Xml.textToDom(block).firstChild);
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.
Reactions are currently unavailable