From cc253295eebe6ebe405f46856e6b93d89b43866f Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 25 May 2022 10:14:34 +0200 Subject: [PATCH] feature: escape on comment now deselects --- app/www/annotate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/www/annotate.js b/app/www/annotate.js index f12a794..9f231a6 100644 --- a/app/www/annotate.js +++ b/app/www/annotate.js @@ -279,7 +279,11 @@ class Annotator extends EventTarget { this.commentEl.placeholder = "comment"; this.commentEl.value = ""; this.commentEl.addEventListener('keyup', (e) => { - e.stopPropagation(); // prevent keyup event to propagate and set i/o points + if (ev.key == 'Escape') { + this.commentEl.blur() // deselect annotation, and deselect commentEl + } else { + e.stopPropagation(); // prevent keyup event to propagate and set i/o points + } }); this.commentEl.addEventListener('input', (e) => { e.stopPropagation(); // prevent keyup event @@ -389,6 +393,7 @@ class Annotator extends EventTarget { this.wrapperEl.classList.remove('selected-annotation'); this.commentEl.value = ""; + this.commentEl.blur(); // make sure we're not typing anymore this.selectedAnnotationI = null; this.selectedAnnotation = null;