Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Update search term when navigating with browser`s back and forward buttons #2101

Merged
merged 12 commits into from
Feb 8, 2023
Merged

Update search term when navigating with browser`s back and forward buttons #2101

merged 12 commits into from
Feb 8, 2023

Conversation

anton202
Copy link
Contributor

Fixes

Fixes #2082 by @obulat

Description

implemented the steps that described in the issue:

  • add query param with the searcn term to the url of the single result page
  • update search term that is saved in the store when navigating from search page

now, when doing a search from a single result page and then going back with the browser button
the search term in the header will be set correctly.

The curent State of staging

current-state-of-staging.mp4

This pull request

searc-term-pr.mp4

Testing Instructions

Follow the steps in the video :)
also, try this steps with an audio result

Checklist

  • My pull request has a descriptive title (not a vague title like
    Update index.md).
  • My pull request targets the default branch of the repository (main) or
    a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible
    errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@anton202 anton202 requested a review from a team as a code owner January 16, 2023 11:42
@anton202 anton202 requested review from zackkrida and dhruvkb January 16, 2023 11:42
@openverse-bot openverse-bot added ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🟩 priority: low Low priority and doesn't need to be rushed labels Jan 16, 2023
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

This looks really good, @anton202! Do you think you could add an e2e test?

@anton202
Copy link
Contributor Author

@obulat sure

@anton202 anton202 marked this pull request as draft January 18, 2023 15:30
@anton202 anton202 marked this pull request as ready for review January 23, 2023 09:20
@anton202
Copy link
Contributor Author

i dont know why the e2e/homepage.spec.ts test is failing... i didnt changed anything related with that test. but anyway, i`ve changed the css selector of the search type pop over, in that test and now it dose pass.

regarding the e2e/translation-banner.spec.ts
when i run all the tests, this test fail
when i run only this test, it pass

@obulat obulat changed the title update search term when navigating with browser`s back and forward buttons Update search term when navigating with browser`s back and forward buttons Jan 31, 2023
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

It works beautifully, @anton202! And the tests are 💯

One request I have is to change the searchTerm to be a prop for VImageCellSquare/VAudioTrack/ VImageCell, and actually get it from the searchStore in the parent components. This way, the searchStore.searchTerm will be called once for each of the media items, and the Cell/Track components will not need to import the useSearchStore.

@anton202
Copy link
Contributor Author

anton202 commented Feb 3, 2023

sure, you rigth :)

* # go back to single result page of cat
* # search term inside the header should be set to cat
*/
test("search term should be set to the search query param on an image type single result page", async ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome test! It currently fails in staging :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so, does this test pass now?

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

Awesome work, thank you, @anton202! Thank you for adding the changes and the test for them!
I've rebased your branch onto main and force-pushed it, so now the CI is green.

@anton202
Copy link
Contributor Author

anton202 commented Feb 8, 2023

@obulat Thank you :)

Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

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

This appears to be working perfectly. Great work @anton202

@zackkrida zackkrida merged commit e31a8ae into WordPress:main Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the search term as a query parameter to the single result page
4 participants