TarekRaafat / autoComplete.js

Simple autocomplete pure vanilla Javascript library.
https://tarekraafat.github.io/autoComplete.js
Apache License 2.0
3.93k stars 236 forks source link

Undefined data inside <li> list items #349

Open inglesuniversal opened 2 years ago

inglesuniversal commented 2 years ago

I have noticed that when pressing the back space key on my computer all the way to leave the input field BLANK, which is used as part of the searchbox for autoComplete, I am inserting unwanted "undefined" values to the unordered list --->

<ul id="autoComplete_list_1" role="listbox" hidden="">
     <li id="autoComplete_result_0" role="option">
           <mark>un</mark>defined</li>
      <li id="autoComplete_result_1" role="option">
           <mark>un</mark>defined</li>
 </ul>

At which part of the code, can I catch this and prevent it from populating the results?

document.querySelector("#autoComplete").addEventListener("close", function (event) {
    let value = event.detail.selection.value;
});

Thanks so much @TarekRaafat

TarekRaafat commented 2 years ago

Hello @inglesuniversal,

Excuse my delayed response. I need more clarification.

  1. When does the undefined value gets inserted, and why?
  2. What are you trying to achieve exactly?

Thanks! :)