Skip to content

Fix user autocomplete queries breaking when custom filter is used - #67

Closed
vkourtis wants to merge 1 commit into
itsarvinddev:masterfrom
vkourtis:fix-custom-filters-breaking-user-autocomplete-queries
Closed

vkourtis wants to merge 1 commit into
itsarvinddev:masterfrom
vkourtis:fix-custom-filters-breaking-user-autocomplete-queries

Conversation

@vkourtis

@vkourtis vkourtis commented Nov 5, 2025

Copy link
Copy Markdown

I was trying to add custom searchFilter in my project to reduce results to certain area (by using locationBias) and could not make it work, until I realized there is a bug where the user's query is not passed.

I worked around the issue by providing a custom PlacesAPI, but I think this fix should do it. Tried it locally on my projects and worked fine.

@itsarvinddev

Copy link
Copy Markdown
Owner

Thank you for this, @vkourtis — and apologies for how long it sat.

Your diagnosis was exactly right, and I want to be clear that your patch targeted the correct file. When you opened this in November, lib/src/autocomplete_service.dart was the live implementation. It was only orphaned later, in b55ba58 (February), when the service moved to lib/src/autocomplete/ and the barrel was repointed — so the code you fixed stopped being the code that runs, through no fault of yours. That is a cost of the PR sitting unreviewed, not a problem with the change.

The fix is in #73, applied to the file that is now live, with your copyWith approach kept:

filter: (filter ?? AutocompleteSearchFilter()).copyWith(
  input: query,
  sessionToken: filter?.sessionToken ?? session.token,
),

One refinement on top of yours: sessionToken: sessionToken.token unconditionally would overwrite a token a developer had set on their own filter, so it now prefers theirs. There is also a regression test (test/autocomplete_filter_test.dart) that pins the behaviour you identified — a caller-supplied regionCode, languageCode, includedRegionCodes, locationBias and friends all survive, and input is always injected.

While reworking that area, the three near-identical copies of AutoCompleteService were collapsed into one, so a fix like yours can only need applying once in future.

Closing as superseded by #73, with the credit yours. Thanks for taking the time to find the root cause rather than working around it — you also saved everyone reading #70 a lot of time.

itsarvinddev added a commit that referenced this pull request Sep 12, 2026
Closes #70, #68, #65, #14. Supersedes #72, #71, #67, #66.

pub.dev score 120/160 -> 160/160. Tests 0 -> 83, green on Flutter 3.38.1 (the declared floor) and 3.47.2.
@itsarvinddev

Copy link
Copy Markdown
Owner

#73 is merged and released as 4.0.0, carrying your change with credit — see the detailed comment above. Closing as superseded, not rejected. Thanks again.

@vkourtis

Copy link
Copy Markdown
Author

Looks good! Thank you for the update @itsarvinddev

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

Successfully merging this pull request may close these issues.

2 participants