Skip to content

Commit

Permalink
Move focusModal() to the end webusbErrorHandle when content is ready.r
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-carlos committed Dec 17, 2019
1 parent 1da4f4e commit decb749
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,16 +1327,9 @@ function web_editor(config) {
// Display error handler modal
$("#flashing-overlay-container").css("display", "flex");
$("#flashing-info").addClass('hidden');
focusModal("#flashing-overlay");
// If escape key is pressed close modal
$('#flashing-overlay').keydown(function(e) {
if (e.which == 27) {
flashErrorClose();
}
});

// Log error to console for feedback
console.log("An error occured whilst attempting to use WebUSB.");
console.log("An error occurred whilst attempting to use WebUSB.");
console.log("Details of the error can be found below, and may be useful when trying to replicate and debug the error.");
console.log(err);
console.trace();
Expand All @@ -1354,7 +1347,7 @@ function web_editor(config) {

// Disconnect from the microbit
doDisconnect();

var errorType;
var errorTitle;
var errorDescription;
Expand Down Expand Up @@ -1457,6 +1450,15 @@ function web_editor(config) {
// Attach download handler
$("#flashing-overlay-download").click(doDownload);

// Make the modal accessible now that all the content is present
focusModal("#flashing-overlay");
// If escape key is pressed close modal
$('#flashing-overlay').keydown(function(e) {
if (e.which == 27) {
flashErrorClose();
}
});

// Send event
var errorMessage = (err.message ? (err.message.replace(/\W+/g, '-').replace(/\W$/, '').toLowerCase()) : "");
// Append error message, replace all special chars with '-', if last char is '-' remove it
Expand Down

0 comments on commit decb749

Please sign in to comment.