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

Instant Search: Use href to restore previous location state #13825

Merged
merged 1 commit into from
Oct 24, 2019

Conversation

jsnmoon
Copy link
Member

@jsnmoon jsnmoon commented Oct 23, 2019

Fixes #13808.

Changes proposed in this Pull Request:

  • Removes reliance on site_url() from PHP.
  • Saves window.location.href on page load for future use.
  • When hiding search results, the initial href on page load is restored onto window.location via the History API.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • No.

Testing instructions:

  • Add define( "JETPACK_SEARCH_PROTOTYPE", true ); to your wp-config.php.
    If using Jetpack's Docker development environment, you can create a file at /docker/mu-plugins/instant-search.php and add the define there.

  • Ensure that your site has the Jetpack Pro plan and Jetpack Search enabled.
    You can enable Jetpack Search in the Performance tab within the Jetpack menu (/wp-admin/admin.php?page=jetpack#/performance).

  • Select a theme of your choosing and add a Jetpack Search widget to the site via the customizer, preferably with some filters enabled. If you're using a theme with a sidebar widget area, please add the Jetpack Search widget there.

  • Navigate to a URL with a query parameter in the URL, like ?testQuery=true.

  • Perform a search by entering some text into the search input box. Ensure that a query string value for your search term has been appended onto the URL (e.g. /?testQuery=true&s=some-search-value).

  • Hide the search interface by deleting the text in the search input box. Ensure that the URL has been restored to /?testQuery=true

Proposed changelog entry for your changes:

  • None.

@jsnmoon jsnmoon added [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Feature] Search For all things related to Search Instant Search labels Oct 23, 2019
@jsnmoon jsnmoon self-assigned this Oct 23, 2019
@jetpackbot
Copy link

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: November 5, 2019.
Scheduled code freeze: October 29, 2019

Generated by 🚫 dangerJS against dd54001

@jsnmoon jsnmoon marked this pull request as ready for review October 23, 2019 22:15
@jsnmoon jsnmoon requested a review from a team as a code owner October 23, 2019 22:15
Copy link
Contributor

@bluefuton bluefuton left a comment

Choose a reason for hiding this comment

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

Works well for me! I had one question about removing siteUrl, but otherwise looks good to go. 🚢

@jeherve jeherve added this to the 7.9 milestone Oct 24, 2019
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Oct 24, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This tests well. Merging.

modules/search/class.jetpack-search.php Show resolved Hide resolved
@jeherve jeherve merged commit 5026e78 into master Oct 24, 2019
@jeherve jeherve deleted the fix/instant-search-url-restoration branch October 24, 2019 12:33
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instant Search: query params get cleared when the search is exited.
5 participants