From 92641c1969334e7fa21b2788109a6737a09af41e Mon Sep 17 00:00:00 2001 From: designitsecure Date: Mon, 7 Oct 2019 18:57:11 -0400 Subject: [PATCH] Fixed dialog windows closing on the Escape key being pressed (dialog must be clicked first) --- CHANGELOG.md | 3 +++ src/main/zapHomeFiles/hud/display.js | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d88145eb9..46fce1e6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added 'Toggle Script' tool, allowing user-made scripts to be toggled on and off from the HUD [#335](https://github.com/zaproxy/zap-hud/issues/335) +### Fixed + - Dialogue windows close properly when the Escape key is pressed [#71](https://github.com/zaproxy/zap-hud/issues/71) + ## [0.7.0] - 2019-10-07 ### Changed diff --git a/src/main/zapHomeFiles/hud/display.js b/src/main/zapHomeFiles/hud/display.js index 57b34e3ac..0ad7651a2 100644 --- a/src/main/zapHomeFiles/hud/display.js +++ b/src/main/zapHomeFiles/hud/display.js @@ -33,7 +33,18 @@ Vue.component('modal', { } app.keepShowing = false; + }, + escapeKey(event) { + if (this.show && (event.key === 'Escape' || event.key === 'Esc')) { + this.close(); + } } + }, + mounted() { + document.addEventListener('keydown', this.escapeKey); + }, + beforeDestroy() { + document.removeEventListener('keydown', this.escapeKey); } });