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: Account for site URL when appending query string #13846

Merged
merged 5 commits into from
Oct 28, 2019

Conversation

jsnmoon
Copy link
Contributor

@jsnmoon jsnmoon commented Oct 25, 2019

Fixes #13845.

Changes proposed in this Pull Request:

  • Propagates output of site_url() to Instant Search's front-end application.
  • Uses the URL API for appending query strings.
  • Imports url-polyfill package to ensure IE 11 support.

Testing instructions:

  • Testing on a WordPress installation at a root URL (e.g. /):

    1. Ensure that you've set up Jetpack Search on your WordPress installation.
    2. Enter text into your Jetpack Search input.
    3. Ensure that your URL is correctly formatted (e.g. /?s=hello)
  • Testing on a WordPress installation at a non-root URL (e.g. /wp-blog):

    1. Ensure that you've set up Jetpack Search on your WordPress installation.
    2. Enter text into your Jetpack Search input.
    3. Ensure that your URL is correctly formatted (e.g. /wp-blog/?s=hello)

Setting up Jetpack Search:

  1. 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.

  2. 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).

  3. 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.

Proposed changelog entry for your changes:

@jsnmoon jsnmoon added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Feature] Search For all things related to Search Instant Search labels Oct 25, 2019
@jsnmoon jsnmoon requested review from bluefuton, jeherve, gibrown and a team October 25, 2019 23:26
@jsnmoon jsnmoon self-assigned this Oct 25, 2019
@jetpackbot
Copy link

jetpackbot commented Oct 25, 2019

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 3671d1d

@jsnmoon jsnmoon added this to the 7.9 milestone Oct 25, 2019
modules/search/class.jetpack-search.php Outdated Show resolved Hide resolved
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Oct 28, 2019
@jsnmoon jsnmoon added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Oct 28, 2019
@jsnmoon jsnmoon requested a review from jeherve October 28, 2019 15:04
Copy link
Member

@gibrown gibrown 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 in almost all cases that I tested (tested on my subdirectory install of WP). The only case I found was when using the back button it didn't reload the original page. For instance, load the homepage and then do a single filter, click back, and although the url gets correctly updated the search results do not get cleared.

We could potentially break this out into a separate issue if it is tough to fix, it is a pretty minor corner case.

@jsnmoon jsnmoon dismissed stale reviews from jeherve and gibrown October 28, 2019 15:59

Updated to use home_url() instead of site_url()

@jsnmoon jsnmoon requested a review from gibrown October 28, 2019 16:00
@jsnmoon
Copy link
Contributor Author

jsnmoon commented Oct 28, 2019

The only case I found was when using the back button it didn't reload the original page.

This should be fixed now; I added handling for popstate events, which are triggered by history.back() and history.forward().

@jeherve jeherve removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Oct 28, 2019
@jeherve jeherve added the [Status] Ready to Merge Go ahead, you can push that green button! label Oct 28, 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.

LGTM. Merging.

@jeherve jeherve merged commit 7ee4919 into master Oct 28, 2019
@jeherve jeherve deleted the fix/instant-search-adding-query branch October 28, 2019 17:13
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Oct 28, 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 [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instant Search: Appending query string doesn't work for sites served from non-root path names
5 participants