@@ -301,12 +301,17 @@ class Blocks extends React.Component {
301
301
onWorkspaceMetricsChange ( ) {
302
302
const target = this . props . vm . editingTarget ;
303
303
if ( target && target . id ) {
304
- this . props . updateMetrics ( {
305
- targetID : target . id ,
306
- scrollX : this . workspace . scrollX ,
307
- scrollY : this . workspace . scrollY ,
308
- scale : this . workspace . scale
309
- } ) ;
304
+ // Dispatch updateMetrics later, since onWorkspaceMetricsChange may be (very indirectly)
305
+ // called from a reducer, i.e. when you create a custom procedure.
306
+ // TODO: Is this a vehement hack?
307
+ setTimeout ( ( ) => {
308
+ this . props . updateMetrics ( {
309
+ targetID : target . id ,
310
+ scrollX : this . workspace . scrollX ,
311
+ scrollY : this . workspace . scrollY ,
312
+ scale : this . workspace . scale
313
+ } ) ;
314
+ } , 0 ) ;
310
315
}
311
316
}
312
317
onScriptGlowOn ( data ) {
@@ -353,7 +358,7 @@ class Blocks extends React.Component {
353
358
this . props . updateToolboxState ( toolboxXML ) ;
354
359
}
355
360
356
- if ( this . props . vm . editingTarget && ! this . props . workspaceMetrics [ this . props . vm . editingTarget . id ] ) {
361
+ if ( this . props . vm . editingTarget && ! this . props . workspaceMetrics . targets [ this . props . vm . editingTarget . id ] ) {
357
362
this . onWorkspaceMetricsChange ( ) ;
358
363
}
359
364
@@ -379,8 +384,8 @@ class Blocks extends React.Component {
379
384
}
380
385
this . workspace . addChangeListener ( this . props . vm . blockListener ) ;
381
386
382
- if ( this . props . vm . editingTarget && this . props . workspaceMetrics [ this . props . vm . editingTarget . id ] ) {
383
- const { scrollX, scrollY, scale} = this . props . workspaceMetrics [ this . props . vm . editingTarget . id ] ;
387
+ if ( this . props . vm . editingTarget && this . props . workspaceMetrics . targets [ this . props . vm . editingTarget . id ] ) {
388
+ const { scrollX, scrollY, scale} = this . props . workspaceMetrics . targets [ this . props . vm . editingTarget . id ] ;
384
389
this . workspace . scrollX = scrollX ;
385
390
this . workspace . scrollY = scrollY ;
386
391
this . workspace . scale = scale ;
0 commit comments