aLex
aLex

Reputation: 1

Making autosuggest list all of the items when you click on its textbox

I am trying to use this plugin to be able to list all items when we click on the textbox as well as do basic autocomplete functions. It doesn't seem to be able to do this however unless I am wrong.

http://codepen.io/moroshko/pen/LGNJMy

function getSuggestions(value) {
  const escapedValue = escapeRegexCharacters(value.trim());

  if (escapedValue === '') {
    return languages;
  }

  const regex = new RegExp('^' + escapedValue, 'i');

  return languages.filter(language => regex.test(language.name));
}

I tried to use the above, but it doesn't work and I am unsure if it having the full list would allow me to properly implement it as I would need to make the list appear upon an onClick event. Is there any way to make this work, or is there a better plugin for what I am trying to do?

Upvotes: 1

Views: 44

Answers (1)

Sedat Gokcen
Sedat Gokcen

Reputation: 3270

Take a look at this codepen which has Autosuggests that show suggestions when textbox is focused which is what you want if I'm not wrong.

Basically shouldRenderSuggestions prop is the way to do that.

Upvotes: 1

Related Questions