@@ -139,4 +139,37 @@ suite('Toasts', function () {
139139 assert . isNull ( toast . getAttribute ( 'aria-live' ) ) ;
140140 assert . notEqual ( toast . getAttribute ( 'role' ) , Blockly . utils . aria . Role . STATUS ) ;
141141 } ) ;
142+
143+ suite ( 'dismiss focus' , function ( ) {
144+ function closeToast ( workspace ) {
145+ const closeButton = workspace
146+ . getInjectionDiv ( )
147+ . querySelector ( '.blocklyToastCloseButton' ) ;
148+ closeButton . focus ( ) ;
149+ closeButton . click ( ) ;
150+ }
151+
152+ test ( 'restores previously focused node on click' , function ( ) {
153+ const block = this . workspace . newBlock ( 'text_print' ) ;
154+ block . initSvg ( ) ;
155+ block . render ( ) ;
156+ Blockly . getFocusManager ( ) . focusNode ( block ) ;
157+ Blockly . Toast . show ( this . workspace , { message : 'texas toast' } ) ;
158+
159+ closeToast ( this . workspace ) ;
160+ assert . isFalse ( this . toastIsVisible ( 'texas toast' ) ) ;
161+ assert . strictEqual ( Blockly . getFocusManager ( ) . getFocusedNode ( ) , block ) ;
162+ } ) ;
163+
164+ test ( 'falls back to workspace focus when nothing was previously focused' , function ( ) {
165+ Blockly . Toast . show ( this . workspace , { message : 'texas toast' } ) ;
166+
167+ closeToast ( this . workspace ) ;
168+ assert . isFalse ( this . toastIsVisible ( 'texas toast' ) ) ;
169+ assert . strictEqual (
170+ Blockly . getFocusManager ( ) . getFocusedNode ( ) ,
171+ this . workspace . getWorkspaceFocusTarget ( ) ,
172+ ) ;
173+ } ) ;
174+ } ) ;
142175} ) ;
0 commit comments