autoComplete.js icon indicating copy to clipboard operation
autoComplete.js copied to clipboard

Open list on focus problems

Open Joanzo opened this issue 2 years ago • 3 comments

https://tarekraafat.github.io/autoComplete.js/#/how-to-guides?id=open-list-on-focus Open list on focus example is not working.

if try from recommendation using space on focus setting. events: { input: { focus() => autoCompleteJS.start(" "); }, },

it will not work on search Engine "strict" mode. While it's working on "loose" mode. i.e: This is not working if there's no space in the list. i.e: [ "Apple", --> this will NOT be shown, "Banana Orange" --> will be shown ]

We don't want to change the searchEngine to "loose" mode as it return weird results.

How to solve this? Thanks

Joanzo avatar Mar 28 '22 03:03 Joanzo

The demo not working anyway (The list do not Open list on focus).

This code works for me:

focus: (event) => {
  console.log("Input Field in focus!");
  const inputValue = autoCompleteJS.input.value;
  autoCompleteJS.start();
  autoCompleteJS.open();
},

This codepen example also working: https://codepen.io/tarekraafat/details/RwKQobg

Ezra-Siton-UIX avatar Apr 18 '22 17:04 Ezra-Siton-UIX

Hello,

The code given by @Ezra-Siton-UIX did not work for me and the codepen provided seems to be an old version of Autocomplete.js.

I have managed to open the list on focus to display all results by adding : trigger: (query) => { return true } and focus: (event) => { search_autoComplete.start(); } To the config options. Result list is still limited by maxResults.

Working Codepen here : https://codepen.io/lucasroquilly/pen/LYQdpXB

I think documentation should be updated to give a working example.

LucasRoquilly avatar May 30 '22 13:05 LucasRoquilly

events: {
  input: {
    focus: () => {
      autoCompleteJS.open();
    },
  },
},

is enough to reopen search results after focusing the input

adriandmitroca avatar Sep 28 '22 18:09 adriandmitroca