Skip to content
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

AutoSuggestBox - Various Details #47

Open
5 tasks done
JLAcostaEC opened this issue May 28, 2022 · 0 comments
Open
5 tasks done

AutoSuggestBox - Various Details #47

JLAcostaEC opened this issue May 28, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@JLAcostaEC
Copy link

JLAcostaEC commented May 28, 2022

Before you start...

  • Have you updated your dependencies? You might be using an old version of the library.
  • Have you checked for an existing issue on this topic? If there is one, post a comment on it instead.

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge, Firefox Beta/Dev/Nightly, Chrome Beta/Dev/Canary, Microsoft Edge Beta/Dev/Canary

Description

  • Do not auto-select the first element of the array.

When AutoSuggestBox is rendered, by default the first array item option is selected by default. It is necessary to prevent this since if the first element is selected it will be impossible to get an event that notifies that the first option has been selected.

I think it could be corrected with:

/** Bindable index of the currently selected item. */
export let selection = -1;

However, some other method could be used that I don't imagine at the moment...

  • Dispatch 'Select' Event does not make sure to update the current value of the AutoSuggestBox

When the 'select' event is fired, it doesn't make sure to update the current value of the AutoSuggestBox , as a result, the event sends the current value but the AutoSuggestBox element keeps the previous value, so calling event.target.value will return the previous value and not the selected/current one

  • Adding the 'on:select' event on component allows better mobile performance

When using the component on mobile, it is much more difficult to fire the 'on:select' event since it is not included in the component, I guess it is because the event is not executed by a click, but rather it is executed by a touch . Carrying out some tests I was able to obtain good results by adding:

on:select={() => {
	if (open && matches.length > 0) value = matches[selection];
}}
on:select

... to the component wrapper.

//////

I'll be running various tests to improve overall performance, so I may submit a pull request regarding this.

Regards... :

Steps To Reproduce

  1. Just try to select the first element and execute an function... you will not be able to get any event on it
  2. On mobile/desktop select one element then select another and another and another, you will see that it will always be the previous value when the select/change/search event are fired.
  3. Better mobile compatibility.

Expected behavior

  1. Do not auto-select the first element of the array.
  2. Dispatch 'Select' Event should make sure to update the current value of the AutoSuggestBox
  3. Better performance on touch screens

Relevant Assets

No response

@JLAcostaEC JLAcostaEC added the bug Something isn't working label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant