Strange behaviour of "getSuggestion"

If you use suggest with dynamic loading, you always get the first element of the list.
If you use local data for suggest, it works differently.

https://snippet.webix.com/g4dn66ir

Hello @lBeJIuk,
Could you please clarify the use-case?
As described in our API, the getSuggestion method returns the first result from the current list of values.
In our code, this method is called after filtering.
What filtering is:

  • for client data, this is just a call to filter which is called immediately
  • for loaded data and server filtering - reloading the results (i.e., an asynchronous request that receives a list of matching values). Client-side filtering and checks are not involved here.

If you call getSuggestion before the data is reloaded, it will simply return the first record it has.

For client data, there really is an additional check so that it returns null for sure if there is no match, but nothing is needed to reload - the server will return either a list of results or an empty array.

@annazankevich
Yes. Thank you. Now I understand the logic more.

Now I noticed another behavior - if you filter by an empty value, getSuggestion returns an empty string instead of the first item.

@annazankevich
In addition, I found a strange behavior of the input.
If an empty answer comes from the server, the text entered before is erased.

https://snippet.webix.com/i15r6lc7

@lBeJIuk,

Now I noticed another behavior - if you filter by an empty value, getSuggestion returns an empty string instead of the first item.

If you filter by “empty” value, it always returns null. If there is no text, filtering is “cleared”, so nothing will be searched for.

In addition, I found a strange behavior of the input.If an empty answer comes from the server, the text entered before is erased.

Please note that the dataFeed property cannot return data.
Generally, it will work correctly with clearAll() + parse() (or load()) - that is, with an explicit call to methods for loading data.
Please take a look at the following example:
https://snippet.webix.com/knk4y8z1

@annazankevich
Thank you for the answer! But unfortunately this does not work with load().
https://snippet.webix.com/atmkltyx

Here is a working example with dynamic loading of results and filtering:
https://snippet.webix.com/4ohad8au
If dynamic loading is needed not only on init, but also for correct loading of options in the presence of filtration you need to replace the URL. Thus, the typed text will always be included in the URL that will be used.

@annazankevich
Thank you!!!. I got it. I need to call “clearAll” additionally.

Sorry for so many questions =). Hopefully the last one. :sweat_smile:
If you do not set “value” and start searching for something, then press “esc” and continue searching, the value you entered earlier will be erased.

https://snippet.webix.com/g7gqid03

Hello @lBeJIuk ,
I can confirm the issue - it seems that a problem with resetting the value. Thank you for reporting it!
As a temporary workaround, try to use the following code: Code Snippet I hope this can be helpful to you.