From e85906d50d818c0c255adb122018c5303365497b Mon Sep 17 00:00:00 2001 From: Benedict Aas Date: Fri, 18 Nov 2016 12:55:30 +0000 Subject: [PATCH] fix(GUI): pressing escape cancels modal dialogue (#878) Pressing the ESC key in any modal dialogue currently just emits a message. This change actually cancels the modal, closing it. Closes: https://github.com/resin-io/etcher/issues/874 Change-Type: patch Changelog-Entry: Allow the user to press ESC to cancel a modal dialog. --- lib/gui/components/modal/services/modal.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/gui/components/modal/services/modal.js b/lib/gui/components/modal/services/modal.js index 31927769..eba4da83 100644 --- a/lib/gui/components/modal/services/modal.js +++ b/lib/gui/components/modal/services/modal.js @@ -59,10 +59,15 @@ module.exports = function($uibModal, $q) { .then(resolve) .catch((error) => { + // Bootstrap doesn't 'resolve' these but cancels the dialog; + // therefore call 'resolve' here applied to 'false'. + if (error === 'escape key press' || error === 'backdrop click') { + resolve(false); + // For some annoying reason, UI Bootstrap Modal rejects // the result reason if the user clicks on the backdrop // (e.g: the area surrounding the modal). - if (error !== 'backdrop click') { + } else if (error !== 'backdrop click') { return reject(error); }