@@ -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 ) ;
0 commit comments