Skip to content

Commit decb749

Browse files
Move focusModal() to the end webusbErrorHandle when content is ready.r
1 parent 1da4f4e commit decb749

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

python-main.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)