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

[BUG] The package filters online results even if isFilteredOnline is set to true, causing some results loaded via onFind to get filtered and removed. #116

Closed
NamanShergill opened this issue Feb 19, 2021 · 4 comments

Comments

@NamanShergill
Copy link

How to reproduce

For example, if one were to search "Delh" via the Nominatim API in the onFind param and return the results, one of the results would be "Valz-sous-Châteauneuf, Issoire, Puy-de-Dôme, Auvergne-Rhône-Alpes, Metropolitan France, 63580, France". This result would get filtered, even if the flag isFilteredOnline is set to true.

What is causing this

List<T> applyFilter(String filter) {

List<T> applyFilter(String filter) {
      return _items.where((i) {
        if (widget.filterFn != null)
          return (widget.filterFn(i, filter));
        else if (i.toString().toLowerCase().contains(filter.toLowerCase()))
          return true;
        else if (widget.itemAsString != null) {
          return (widget.itemAsString(i))
                  ?.toLowerCase()
                  ?.contains(filter.toLowerCase()) ??
              false;
        }
        return false;
      }).toList();
    }

As you can see, it filters the result in else if (i.toString().toLowerCase().contains(filter.toLowerCase())), because technically "delh" is not in the string "Valz-sous-Châteauneuf, Issoire, Puy-de-Dôme, Auvergne-Rhône-Alpes, Metropolitan France, 63580, France", causing it to get filtered out.

Expected Behavior

Considering isFilteredOnline is set to true, the dropdown should show all results by default, considering the flag itself implies the filtering is already done online by the API.

How it might be fixed

The applyFilter function should not be used for the results given by the API in this scenario (unless the user specifically passes filterFn).

@salim-lachdhaf
Copy link
Owner

fixed in v0.4.9

@NamanShergill
Copy link
Author

NamanShergill commented Feb 22, 2021

fixed in v0.4.9

I just tested this version, the bug still seems to be happening.

@NamanShergill
Copy link
Author

@salim-lachdhaf Could this issue please be re-opened, the bug is still occurring.

@salim-lachdhaf
Copy link
Owner

fixed in v0.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants