From e7643992b1eb50ba0d9f64f82004090f87deab71 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Tue, 13 Jul 2021 18:06:46 -0400 Subject: [PATCH] Reset the state correctly if a dashboard modal is cancelled with the escape button --- resources/js/dashboard.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/resources/js/dashboard.js b/resources/js/dashboard.js index 67d523e..7b00d3c 100644 --- a/resources/js/dashboard.js +++ b/resources/js/dashboard.js @@ -48,10 +48,19 @@ function askConfirmation(message, command, cancelCommand) { }, fadeTime); }; + // functionality to run when clicking the cancel button + const cancelModal = function() { + if (cancelCommand !== undefined) { + cancelCommand(); + } + + closeConfirmationModal(); + }; + // close the modal if the escape button is pressed const escapeModal = function(e) { if (e.keyCode === 27) { - closeConfirmationModal(); + cancelModal(); } else { e.preventDefault(); } @@ -63,15 +72,6 @@ function askConfirmation(message, command, cancelCommand) { closeConfirmationModal(); }; - // functionality to run when clicking the cancel button - const cancelModal = function() { - if (cancelCommand !== undefined) { - cancelCommand(); - } - - closeConfirmationModal(); - }; - // hide the modal when the cancel button is pressed $cancelButton.on("click", cancelModal);