dotMorten / MauiEx

A set of .NET MAUI controls
Apache License 2.0
224 stars 55 forks source link

On Android, setting IsSuggestionListOpen = true doesn't work when Text is empty #61

Closed rh-mitre-ten closed 4 years ago

rh-mitre-ten commented 4 years ago

Description

We're hoping to use this control for two purposes: a) when the Text field is empty, show the user a set of past searches - whether the user has just set the focus to an empty control, or, has deleted the last character b) once the user types, hide the suggestions until the user has typed enough characters that we can provide search suggestions from an API

The control gives us this behaviour on iOS; however, on Android, because of this defined behaviour: https://developer.android.com/reference/android/widget/AutoCompleteTextView.html?hl=de#setThreshold%28int%29 the control will not display the suggestion list if the Text property is empty. Setting Threshold=0, as is done in the current code, is not the solution since a value of 0 is treated the same as a value of 1, by design.

According to the following StackOverflow article, one way to force this behaviour is to override the EnoughToFilter() method to always return true. https://stackoverflow.com/questions/2126717/android-autocompletetextview-show-suggestions-when-no-text-entered

Using your source code I have verified that the above change to the NativeAutoSuggestBox.Android.cs file would give us the behaviour we're looking for.

Is this a change you would be willing to make? If not, how is this code licensed and may we fork it?

Version 1.0.0

dotMorten commented 4 years ago

That sounds like a great find! Thank you! Could you submit a PR and I'll review as soon as I can?

dotMorten commented 4 years ago

Fixed with above PR. Thank you!

dotMorten commented 4 years ago

Published as v1.0.1