ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

RadAutoCompleteTextView doesn't show 'Not Found' message when loadSuggestionsAsync Promise resolves with [] - shows loading spinner instead #1399

Open csimpi opened 4 years ago

csimpi commented 4 years ago

Please take a minute to read our NativeScript Code of Conduct before proceeding with posting issues or discussing. The purpose of this guide is to make communication and cooperation within our forums a pleasure for you and the other members.

Please, provide the details below:

Tell us about the problem

When I use loadSuggestionsAsync with RadAutoCompleteTextView I can't show up the No Results message. If I resolve the Promise with an empty array [] it shows loading spinner instead of No Results message.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

√ Getting NativeScript components versions information... √ Component nativescript has 6.5.0 version and is up to date. √ Component tns-core-modules has 6.5.1 version and is up to date. √ Component tns-android has 6.5.1 version and is up to date. × Component tns-ios is not installed.

Please tell us how to recreate the issue in as much detail as possible.

Open this sample and follow the instructions on the screen: https://play.nativescript.org/?template=play-ng&id=18mghh

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

(You can paste entire code snippets, link to playground demo or attach a runnable project)

facetious commented 4 years ago

This happens because the so-called async isn't actually asynchronous. Because JavaScript is single-threaded, the Promise happens to be resolved all-at-once. There's a race condition here in the library (and a simple patch to change the order of calls might be sufficient), but for now, I would recommend making your asynchronous filter actually asynchronous. It is enough to replace the resolve(items) with:

                setTimeout(() => resolve(items), 0);

https://play.nativescript.org/?template=play-ng&id=18mghh&v=2

csimpi commented 4 years ago

@facetious Nice workaround, and thank you for the explanation!