Merge pull request #2667 from chrisgarrity/issue/2530-block-size-locale

Issue/2530 block size locale
This commit is contained in:
chrisgarrity authored and GitHub committed 2018-07-18 14:22:17 -04:00
commit d5aa29a395
2 files changed
+14 -7

No files matched your search

+1 -1
View File
@@ -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",
+13 -6
View File
@@ -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'));