Skip to content

fix: Update search page when changing terms - #2992

Merged
lucasfp13 merged 1 commit into
mainfrom
fix/SFS-2764-update-search-page-when-changing-terms
Sep 1, 2025
Merged

lucasfp13 merged 1 commit into
mainfrom
fix/SFS-2764-update-search-page-when-changing-terms

Conversation

@lucasfp13

@lucasfp13 lucasfp13 commented Aug 14, 2025 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Currently, after performing a new search, when the shopper is already in the search page, the results are not changing. Also, the results are not being updated when the zip code is changed.

With these changes, the search page will consider the correct term when performing the search and will refetch the query when the zip code is changed.

How to test it?

  • Search for apple. You should see apple results;
  • Still in the search page, search again for unbranded and the results should be different (showing results for unbranded);

Starters Deploy Preview

dp-faststore-org/vendemo-dp#74
vtex-sites/faststoreqa.store#857

References

@lucasfp13 lucasfp13 self-assigned this Aug 14, 2025
@lucasfp13
lucasfp13 requested a review from a team as a code owner August 14, 2025 17:57
@lucasfp13 lucasfp13 added the bug Something isn't working label Aug 14, 2025
@lucasfp13
lucasfp13 requested review from eduardoformiga and ommeirelles and removed request for a team August 14, 2025 17:57
@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

})

const shouldFetch =
!hasSameVariables || shouldFetchFirstPage || !!sessionPostalCode

@lucasfp13 lucasfp13 Aug 14, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this line (adding the !!sessionPostalCode)

const shouldFetch =
!hasSameVariables || shouldFetchFirstPage || !!sessionPostalCode

const { data, mutate } = useQuery<

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this line (adding the mutate)

Comment on lines +156 to +162
// Refetch query with updated regionId
useEffect(() => {
if (sessionPostalCode !== postalCodeRef.current) {
mutate()
postalCodeRef.current = sessionPostalCode
}
}, [sessionPostalCode])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this line (adding the useEffect to refetch the query)

@lucasfp13
lucasfp13 merged commit 90be90f into main Sep 1, 2025
@lucasfp13
lucasfp13 deleted the fix/SFS-2764-update-search-page-when-changing-terms branch September 1, 2025 12:14
lariciamota added a commit that referenced this pull request Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants