Skip to content

Commit

Permalink
EGON-31: Fix autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Dymel committed Jan 16, 2024
1 parent b3dc373 commit 63d8221
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/Modeler/modeler/labeling/dsLabelUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function autocomplete(input, workObjectNames, element, eventBus) {

/* the autocomplete function takes three arguments,
the text field element and an array of possible autocompleted values and an optional element to which it is appended:*/
let currentFocus;
let currentFocus, filteredWorkObjectNames;

/* execute a function when someone writes in the text field:*/
input.addEventListener("input", function () {
Expand Down Expand Up @@ -139,6 +139,7 @@ export function autocomplete(input, workObjectNames, element, eventBus) {
this.parentNode.appendChild(autocompleteList);

/* for each item in the array...*/
filteredWorkObjectNames = [];
for (const name of workObjectNames) {
/* check if the item starts with the same letters as the text field value:*/
if (val) {
Expand All @@ -157,6 +158,8 @@ export function autocomplete(input, workObjectNames, element, eventBus) {
autocompleteItem.innerHTML +=
"<input type='hidden' value='" + name + "'>";
autocompleteList.appendChild(autocompleteItem);

filteredWorkObjectNames.push(name);
}
}
}
Expand Down Expand Up @@ -192,7 +195,7 @@ export function autocomplete(input, workObjectNames, element, eventBus) {
e.preventDefault();
/* If the ENTER key is pressed, prevent the form from being submitted,*/
if (currentFocus > -1) {
element.businessObject.name = workObjectNames[currentFocus];
element.businessObject.name = filteredWorkObjectNames[currentFocus];
eventBus.fire("element.changed", { element });
}
}
Expand Down

0 comments on commit 63d8221

Please sign in to comment.