@@ -1327,16 +1327,9 @@ function web_editor(config) {
13271327        // Display error handler modal 
13281328        $ ( "#flashing-overlay-container" ) . css ( "display" ,  "flex" ) ; 
13291329        $ ( "#flashing-info" ) . addClass ( 'hidden' ) ; 
1330-         focusModal ( "#flashing-overlay" ) ; 
1331-         // If escape key is pressed close modal 
1332-         $ ( '#flashing-overlay' ) . keydown ( function ( e )  { 
1333-             if  ( e . which  ==  27 )  { 
1334-                 flashErrorClose ( ) ; 
1335-            } 
1336-        } ) ; 
13371330
13381331        // Log error to console for feedback 
1339-         console . log ( "An error occured  whilst attempting to use WebUSB." ) ; 
1332+         console . log ( "An error occurred  whilst attempting to use WebUSB." ) ; 
13401333        console . log ( "Details of the error can be found below, and may be useful when trying to replicate and debug the error." ) ; 
13411334        console . log ( err ) ; 
13421335        console . trace ( ) ; 
@@ -1354,7 +1347,7 @@ function web_editor(config) {
13541347
13551348        // Disconnect from the microbit 
13561349        doDisconnect ( ) ; 
1357-         
1350+ 
13581351        var  errorType ; 
13591352        var  errorTitle ; 
13601353        var  errorDescription ; 
@@ -1457,6 +1450,15 @@ function web_editor(config) {
14571450        // Attach download handler 
14581451        $ ( "#flashing-overlay-download" ) . click ( doDownload ) ; 
14591452
1453+         // Make the modal accessible now that all the content is present 
1454+         focusModal ( "#flashing-overlay" ) ; 
1455+         // If escape key is pressed close modal 
1456+         $ ( '#flashing-overlay' ) . keydown ( function ( e )  { 
1457+             if  ( e . which  ==  27 )  { 
1458+                 flashErrorClose ( ) ; 
1459+            } 
1460+         } ) ; 
1461+ 
14601462        // Send event 
14611463        var  errorMessage  =  ( err . message  ? ( err . message . replace ( / \W + / g,  '-' ) . replace ( / \W $ / ,  '' ) . toLowerCase ( ) )  : "" ) ; 
14621464        // Append error message, replace all special chars with '-', if last char is '-' remove it 
0 commit comments