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

[Hackdays 36] Search from url #12327

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

sirgalleto
Copy link
Contributor

@sirgalleto sirgalleto commented Jul 2, 2024

WHY are these changes introduced?

As a developer, my regular usage pattern of Polaris is:

  1. Go to polaris.shopify.com
  2. Wait for load
  3. Type / to open the search
  4. Write the search.

But it can be more efficient, and we don't need to reinvent the wheel. You can go to google.com/search?q=Shopify. In Chrome, you can even type google.com + tab and write your search directly on the bar.

This PR Implements the route https://polaris.shopify.com/search?q={searchTerm} intended to be used as a search-ready URL, now (and using the chrome site search config) the search experience can be:

  1. Open a new tab
  2. Write your site search shorcut ("pol" in my case)
  3. Write your search.
  4. Go!

Demo

Screen.Recording.2024-07-01.at.11.55.30.p.m.mov

WHAT is this pull request doing?

1. Fix a useThrottle hook's race condition that prevents the first event from being fire.

This is testable by going to polaris.com, opening the search and type one key; the result is the search non being fired

2. Create the search route
  1. Create a search component exporting the same index component.
  2. In the <GlobalSearch/> component, watch for the route and search term to open and fill the search.

How to 🎩

  1. cd polaris.shopify.com && pnpm dev
  2. Go to localhost:3000/search&q=Any Search term
  3. You should see the search bar populated by default.

🎩 checklist

@sirgalleto sirgalleto requested a review from alex-page July 2, 2024 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant