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

[Feature] Bring back minCharsForSuggestions property #609

Closed
bahadirarslan opened this issue Oct 30, 2024 · 5 comments
Closed

[Feature] Bring back minCharsForSuggestions property #609

bahadirarslan opened this issue Oct 30, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@bahadirarslan
Copy link

Use case

I have been using your library for 2 years and it was a perfect fit for my project. But you removed minCharsForSuggestions property with version 5.0.0 and suggested checking string length at suggestionsCallback.

If I was using this widget in one screen it could be manageable but I am using this widget almost in 20 different widgets so I created the AutoCompleteTextField widget for myself which is using your widget.

This means I had to add dozens of screens' char length check to show suggestions. Instead of doing this chore, I wrote below code
suggestionsCallback: (search) => search.isNotEmpty && search.length >= 3 ? widget.suggestionsCallback(search) : [],

If it was enough, this could be OK, but it is not. The minCharsForSuggestions value also hide emptyBuilder if the value was below the threshold. With this new implementation, when the field gets focus, it automatically shows emptyBuilder, which is unwanted because the user hasn't typed anything yet.

Now I am trying to find a way to bypass this behaviour.

Proposal

Bring back minCharsForSuggestions property like version 4.x

@bahadirarslan bahadirarslan added the enhancement New feature or request label Oct 30, 2024
@BunnyBuddy
Copy link

Have you tried hideOnEmpty property?

Use case

I have been using your library for 2 years and it was a perfect fit for my project. But you removed minCharsForSuggestions property with version 5.0.0 and suggested checking string length at suggestionsCallback.

If I was using this widget in one screen it could be manageable but I am using this widget almost in 20 different widgets so I created the AutoCompleteTextField widget for myself which is using your widget.

This means I had to add dozens of screens' char length check to show suggestions. Instead of doing this chore, I wrote below code suggestionsCallback: (search) => search.isNotEmpty && search.length >= 3 ? widget.suggestionsCallback(search) : [],

If it was enough, this could be OK, but it is not. The minCharsForSuggestions value also hide emptyBuilder if the value was below the threshold. With this new implementation, when the field gets focus, it automatically shows emptyBuilder, which is unwanted because the user hasn't typed anything yet.

Now I am trying to find a way to bypass this behaviour.

Proposal

Bring back minCharsForSuggestions property like version 4.x

@bahadirarslan
Copy link
Author

Have you tried hideOnEmpty property?

Use case

I have been using your library for 2 years and it was a perfect fit for my project. But you removed minCharsForSuggestions property with version 5.0.0 and suggested checking string length at suggestionsCallback.

If I was using this widget in one screen it could be manageable but I am using this widget almost in 20 different widgets so I created the AutoCompleteTextField widget for myself which is using your widget.

This means I had to add dozens of screens' char length check to show suggestions. Instead of doing this chore, I wrote below code suggestionsCallback: (search) => search.isNotEmpty && search.length >= 3 ? widget.suggestionsCallback(search) : [],

If it was enough, this could be OK, but it is not. The minCharsForSuggestions value also hide emptyBuilder if the value was below the threshold. With this new implementation, when the field gets focus, it automatically shows emptyBuilder, which is unwanted because the user hasn't typed anything yet.

Now I am trying to find a way to bypass this behaviour.

Proposal

Bring back minCharsForSuggestions property like version 4.x

Yes, I tried but it is not suitable for my case. Because I show add new button if the suggestion list is empty. If I use hideOnEmpty option nothing is shown. minCharsForSuggestions was perfect, why it was removed at all?

@kirpit
Copy link

kirpit commented Nov 23, 2024

I had the same feeling when first upgraded because of a similar use case; I don't want emptyBuilder to display before the 3rd char.. But if you pay close attention, the return type is List<T>? - which means you can return null instead of an empty array 😉

@bahadirarslan
Copy link
Author

I had the same feeling when first upgraded because of a similar use case; I don't want emptyBuilder to display before the 3rd char.. But if you pay close attention, the return type is List<T>? - which means you can return null instead of an empty array 😉

Nice catch :)
Returning null solved my problem. But still I think it was not necessary to remove minCharsForSuggestion

@clragon
Copy link
Collaborator

clragon commented Nov 25, 2024

We have intentionally removed this feature to reduce package complexity and chosen to instead empower users through other means, such as returning null to hide the emptyBuilder under any custom condition. Because of that, it is unlikely this feature will return. I will see if we can update the readme to clarify the usage of null here.

@clragon clragon closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants