Skip to content

Commit c589f3a

Browse files
committed
Merge remote-tracking branch 'gonfunko/modern-blockly' into spork
2 parents 0e2d471 + fb762c2 commit c589f3a

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/containers/blocks.jsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ class Blocks extends React.Component {
299299
.then(() => {
300300
this.workspace.getFlyout().setRecyclingEnabled(false);
301301
this.props.vm.refreshWorkspace();
302+
this.requestToolboxUpdate();
302303
this.withToolboxUpdates(() => {
303304
this.workspace.getFlyout().setRecyclingEnabled(true);
304305
});
@@ -316,27 +317,28 @@ class Blocks extends React.Component {
316317
const selectedCategoryScrollPosition =
317318
this.workspace
318319
.getFlyout()
319-
.getCategoryScrollPosition(selectedCategoryName).y * scale;
320+
.getCategoryScrollPosition(selectedCategoryName) * scale;
320321
const offsetWithinCategory =
321322
this.workspace.getFlyout().getWorkspace().getMetrics().viewTop -
322323
selectedCategoryScrollPosition;
323324

324325
this.workspace.updateToolbox(this.props.toolboxXML);
326+
this.workspace.getToolbox().runAfterRerender(() => {
327+
const newCategoryScrollPosition = this.workspace
328+
.getFlyout()
329+
.getCategoryScrollPosition(selectedCategoryName);
330+
if (newCategoryScrollPosition) {
331+
this.workspace
332+
.getFlyout()
333+
.getWorkspace()
334+
.scrollbar.setY(
335+
newCategoryScrollPosition * scale + offsetWithinCategory
336+
);
337+
}
338+
});
325339
this.workspace.getToolbox().forceRerender();
326340
this._renderedToolboxXML = this.props.toolboxXML;
327341

328-
const newCategoryScrollPosition = this.workspace
329-
.getFlyout()
330-
.getCategoryScrollPosition(selectedCategoryName);
331-
if (newCategoryScrollPosition) {
332-
this.workspace
333-
.getFlyout()
334-
.getWorkspace()
335-
.scrollbar.setY(
336-
newCategoryScrollPosition.y * scale + offsetWithinCategory
337-
);
338-
}
339-
340342
const queue = this.toolboxUpdateQueue;
341343
this.toolboxUpdateQueue = [];
342344
queue.forEach((fn) => fn());
@@ -520,7 +522,7 @@ class Blocks extends React.Component {
520522
this.workspace.removeChangeListener(this.toolboxUpdateChangeListener);
521523
const dom = this.ScratchBlocks.utils.xml.textToDom(data.xml);
522524
try {
523-
this.ScratchBlocks.Xml.clearWorkspaceAndLoadFromXml(
525+
this.ScratchBlocks.clearWorkspaceAndLoadFromXml(
524526
dom,
525527
this.workspace
526528
);

src/lib/blocks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ export default function (vm, useCatBlocks) {
410410
return ScratchBlocks.StatusButtonState.NOT_READY;
411411
};
412412

413-
// ScratchBlocks.FieldNote.playNote_ = function (noteNum, extensionId) {
414-
// vm.runtime.emit('PLAY_NOTE', noteNum, extensionId);
415-
// };
413+
ScratchBlocks.FieldNote.playNote_ = function (noteNum, extensionId) {
414+
vm.runtime.emit("PLAY_NOTE", noteNum, extensionId);
415+
};
416416

417417
// Use a collator's compare instead of localeCompare which internally
418418
// creates a collator. Using this is a lot faster in browsers that create a

0 commit comments

Comments
 (0)