Closed mark-friedman closed 4 months ago
I noticed that if I have only one block selected and I simply change a field value while in multiFieldUpdate mode that the validator for that field runs twice - once directly for the user-initiated change and again as the eventListener_ handler in the plugin calls setFieldValue when it gets the change event.
I guess this can be avoided by checking the event source and avoid calling the setFieldValue
if that specific block happens to be the event source. I will implement this change.
Also note that there appears to be a cascade of many calls to setFieldValue if multiple blocks are selected. Since validators may have side effects, this is undesirable behavior.
This is interesting, currently we just blindly listen to the field change event generated from Blockly, so if the above change doesn't get this fixed, I'm not aware of any more ways to stop this from happening at our plugin side, and then I guess something might need to be done for the validators themselves / at the Blockly side to get this properly fixed.
I'll check on the cascading and will reopen this if there remains an issue.
Unfortunately, the cascading continues, despite the latest change. I don't think that it's reasonable for devs to have to adapt their validators, but if we need something from Blockly we can certainly ask them. Maybe @ewpatton has some ideas.
In the meantime, I think that we'll have to turn off multiFieldUpdate
for App Inventor until this is resolved.
BTW, it's fairly easy to reproduce this by:
npm start
in the multiselect plugin directoryFixed the cascading issue by checking if the group id is empty, since all the automated operations have a group id.
Check for duplicates
Description
I noticed that if I have only one block selected and I simply change a field value while in multiFieldUpdate mode that the validator for that field runs twice - once directly for the user-initiated change and again as the
eventListener_
handler in the plugin callssetFieldValue
when it gets the change event. Also note that there appears to be a cascade of many calls tosetFieldValue
if multiple blocks are selected. Since validators may have side effects, this is undesirable behavior.Reproduction steps
Stack trace
No response
Screenshots
No response
Browsers
No response