99 closeSpriteLibrary
1010} from '../reducers/modals' ;
1111
12- import { activateTab , COSTUMES_TAB_INDEX } from '../reducers/editor-tab' ;
12+ import { activateTab , COSTUMES_TAB_INDEX , BLOCKS_TAB_INDEX } from '../reducers/editor-tab' ;
1313import { setReceivedBlocks } from '../reducers/hovered-target' ;
1414import { setRestore } from '../reducers/restore-deletion' ;
1515import DragConstants from '../lib/drag-constants' ;
@@ -23,6 +23,7 @@ class TargetPane extends React.Component {
2323 constructor ( props ) {
2424 super ( props ) ;
2525 bindAll ( this , [
26+ 'handleActivateBlocksTab' ,
2627 'handleBlockDragEnd' ,
2728 'handleChangeSpriteRotationStyle' ,
2829 'handleChangeSpriteDirection' ,
@@ -72,7 +73,9 @@ class TargetPane extends React.Component {
7273 this . props . vm . postSpriteInfo ( { y} ) ;
7374 }
7475 handleDeleteSprite ( id ) {
75- const restoreFun = this . props . vm . deleteSprite ( id ) ;
76+ const restoreSprite = this . props . vm . deleteSprite ( id ) ;
77+ const restoreFun = ( ) => restoreSprite ( ) . then ( this . handleActivateBlocksTab ) ;
78+
7679 this . props . dispatchUpdateRestore ( {
7780 restoreFun : restoreFun ,
7881 deletedItem : 'Sprite'
@@ -109,7 +112,8 @@ class TargetPane extends React.Component {
109112 }
110113 handleSurpriseSpriteClick ( ) {
111114 const item = spriteLibraryContent [ Math . floor ( Math . random ( ) * spriteLibraryContent . length ) ] ;
112- this . props . vm . addSprite ( JSON . stringify ( item . json ) ) ;
115+ this . props . vm . addSprite ( JSON . stringify ( item . json ) )
116+ . then ( this . handleActivateBlocksTab ) ;
113117 }
114118 handlePaintSpriteClick ( ) {
115119 const formatMessage = this . props . intl . formatMessage ;
@@ -124,8 +128,12 @@ class TargetPane extends React.Component {
124128 } ) ;
125129 } ) ;
126130 }
131+ handleActivateBlocksTab ( ) {
132+ this . props . onActivateTab ( BLOCKS_TAB_INDEX ) ;
133+ }
127134 handleNewSprite ( spriteJSONString ) {
128- this . props . vm . addSprite ( spriteJSONString ) ;
135+ this . props . vm . addSprite ( spriteJSONString )
136+ . then ( this . handleActivateBlocksTab ) ;
129137 }
130138 handleFileUploadClick ( ) {
131139 this . fileInput . click ( ) ;
0 commit comments