1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 07:52:23 +00:00

Enter key clicks on the first alias

This commit is contained in:
Yohann D'ANELLO 2020-03-13 12:21:33 +01:00
parent 1e6891e1c7
commit 6747f4340d

View File

@ -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 === "")