From 6747f4340d21b58a147db0a98ed6ea01636947e9 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 13 Mar 2020 12:21:33 +0100 Subject: [PATCH] Enter key clicks on the first alias --- static/js/base.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/static/js/base.js b/static/js/base.js index 622a13f4..50462daa 100644 --- a/static/js/base.js +++ b/static/js/base.js @@ -126,8 +126,18 @@ function autoCompleteNote(field_id, alias_matched_id, note_list_id, notes, notes let old_pattern = null; + // When the user type "Enter", the first alias is clicked + field.keypress(function(event) { + console.log(event.originalEvent); + if (event.originalEvent.charCode === 13) + $("#" + alias_matched_id + " li").first().trigger("click"); + }); + // When the user type something, the matched aliases are refreshed - field.keyup(function() { + field.keyup(function(e) { + if (e.originalEvent.charCode === 13) + return; + let pattern = field.val(); // If the pattern is not modified, or if the field is empty, we don't query the API if (pattern === old_pattern || pattern === "")