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: Appending query string doesn't work for sites served from non-root path names #13845

Closed
jsnmoon opened this issue Oct 25, 2019 · 1 comment · Fixed by #13846
Closed
Assignees
Labels
[Feature] Search For all things related to Search [Pri] High [Type] Bug When a feature is broken and / or not performing as intended
Milestone

Comments

@jsnmoon
Copy link
Contributor

jsnmoon commented Oct 25, 2019

Steps to reproduce the issue

  1. Suppose a WordPress site exists at https://example.com/wp-blog with a Jetpack Search widget enabled. (See the first two test steps in Instant Search: Update prototype with downstream changes #13761 for explicit instructions.)
  2. Enter some text into the Jetpack Search input in the above example blog.

What I expected

  • The URL should be set to https://example.com/wp-blog?s=search-term-here.

What happened instead

  • The URL was set to https://example.com/?s=search-term-here.

Actual examples
You can try searching at this URL: http://gibrown.wpsandbox.me/demo/.

@jsnmoon jsnmoon added [Type] Bug When a feature is broken and / or not performing as intended [Pri] High [Feature] Search For all things related to Search Instant Search labels Oct 25, 2019
@jsnmoon jsnmoon self-assigned this Oct 25, 2019
@jsnmoon jsnmoon added this to the 7.9 milestone Oct 25, 2019
@jsnmoon
Copy link
Contributor Author

jsnmoon commented Oct 25, 2019

The tricky part of the fix requires us to know what the actual site URL is. If we don't account for this, we'll run into incorrect behavior like so:


  1. Incorrect approach: always account for the path name when appending a search query string
  • Start browsing a WP site at /.
  • Navigate to the about page at /about/.
  • Type in a search for "hello".
  • Expected URL: /?s=hello. Actual URL: /about/?s=hello. Incorrect!
  1. Incorrect (and current) approach: always revert path name to / when appending a search query string
  • Start browsing a WP site at /wp-blog.
  • Type in a search for "hello".
  • Expected URL: /wp-blog/?s=hello. Actual URL: /?s=hello. Incorrect!
  1. Correct approach: use a base siteUrl whenever we manipulate query strings
  • WP site at / + navigate to /about/ + "hello" search => /?s=hello
  • WP site at /wp-blog + "hello" search => /wp-blog/?s=hello

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 [Pri] High [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant