diff --git a/package.json b/package.json index ce5ccbb4ebd61dab24b87010c346c1924d22946b..8118ea7f39478c7a9f0ed210dfc63c07dda4ea9d 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "scratch-render": "0.1.0-prerelease.20180618173030", "scratch-storage": "0.5.1", "scratch-svg-renderer": "0.2.0-prerelease.20180712223402", - "scratch-vm": "0.1.0-prerelease.1531502959", + "scratch-vm": "0.1.0-prerelease.1531927323", "selenium-webdriver": "3.6.0", "startaudiocontext": "1.2.1", "style-loader": "^0.21.0", diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index 56f2fa5d5fc7979f9f50fa1b0cdc9268596c7d7d..2ea34d2203cdd4a598bbbb5d77a96199c9b80ba1 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -94,7 +94,11 @@ class Blocks extends React.Component { addFunctionListener(this.workspace, 'zoom', this.onWorkspaceMetricsChange); this.attachVM(); - this.setLocale(); + // Only update blocks/vm locale when visible to avoid sizing issues + // If locale changes while not visible it will get handled in didUpdate + if (this.props.isVisible) { + this.setLocale(); + } analytics.pageview('/editors/blocks'); } @@ -117,10 +121,6 @@ class Blocks extends React.Component { this.ScratchBlocks.hideChaff(); } - if (prevProps.locale !== this.props.locale) { - this.setLocale(); - } - if (prevProps.toolboxXML !== this.props.toolboxXML) { // rather than update the toolbox "sync" -- update it in the next frame clearTimeout(this.toolboxUpdateTimeout); @@ -139,7 +139,14 @@ class Blocks extends React.Component { // @todo hack to reload the workspace due to gui bug #413 if (this.props.isVisible) { // Scripts tab this.workspace.setVisible(true); - this.props.vm.refreshWorkspace(); + if (prevProps.locale !== this.props.locale || this.props.locale !== this.props.vm.getLocale()) { + // call setLocale if the locale has changed, or changed while the blocks were hidden. + // vm.getLocale() will be out of sync if locale was changed while not visible + this.setLocale(); + } else { + this.props.vm.refreshWorkspace(); + } + // Re-enable toolbox refreshes without causing one. See #updateToolbox for more info. this.workspace.toolboxRefreshEnabled_ = true; window.dispatchEvent(new Event('resize'));