Skip to content

Wrong item selected on enter #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kinosnai opened this issue Mar 23, 2022 · 2 comments
Closed

Wrong item selected on enter #149

Kinosnai opened this issue Mar 23, 2022 · 2 comments

Comments

@Kinosnai
Copy link

There is a unintended (I guess) behaviour when you press enter AFTER you have selected an item from the list with enter key.
To recreate the issue go to demo page http://simple-svelte-autocomplete.surge.sh/?# and use the first example called "matching keyword strategy" from "advanced usage" tab.

On that example there is an array of animals:

const animals = [

  • "White Rabbit" --> array[0]
  • "White Horse" --> array[1]
  • "Black Rabbit" --> array[2]
  • "Black Horse" --> array[3]
  • "Black Black Rabbit" --> array[4]
    ]

On the autocomplete input field please type "bl" and three items will show on the filtered list array which are:

  • "Black Rabbit" --> array[0]
  • "Black Horse" --> array[1]
  • "Black Black Rabbit" --> array[2]

Use down arrow key to select "Black Horse". The filtered list will close and black horse will stay as value on the input field. Now if you press enter AGAIN the value will change to "White Horse".

I think this behaviour is unintended. For some reason the index [1] of "Black Horse" on the filtered list gets stored and then persists on the second "enter" but this time it selects the index from the whole items list, which in the animals array is "White Horse".

I guess after the first enter event there must be some kind of reseting on the first selected value or another solution could be to prevent the second enter happening on an empty field. Pressing enter for second time with minCharactersToSearch=1 or higher wont prevent this from happening either.

I hope my description helps to fix this, I love the multiple words searching function of this component!!

@pstanoev
Copy link
Owner

Thanks for reporting, reproduced, will be fixed.

@pstanoev
Copy link
Owner

pstanoev commented Jun 1, 2022

Fixed in the latest version.

@pstanoev pstanoev closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants