Skip to content

Clear search input on index route #1875

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

Merged
merged 1 commit into from
Nov 20, 2019

Conversation

jtescher
Copy link
Contributor

Not sure what the correct product choice is here, but this clears the search input when navigating back to index route if that is in fact the behavior that is preferred.

Fixes #1230

(for some context both npm and rubygems.org do NOT clear the index if you search and then navigate back via browser, but both clear if you navigate forward to the index route via top left icon clicks)

@rust-highfive
Copy link

r? @carols10cents

(rust_highfive has picked a reviewer for you, use r? to override)

@carols10cents
Copy link
Member

Hm, I'm not sure this is what we want. The behavior you described is working as you intend, but it's leading to some unexpected results. When trying this out locally with npm run start:local, if i:

Another unexpected scenario:

Is it possible to set the search query to what's in the current URL's q parameter (if there is one) instead of null unconditionally? And is it possible to set the search query in this manner for all routes, not only /?

What do you think?

@jtescher
Copy link
Contributor Author

I can do that if it the right product choice, could also decide to close this pr and the underlying issue if it is working as intended currently.

@carols10cents
Copy link
Member

I think we should make a change to the current behavior, if you're up for continuing to work on this. Thanks!

@jtescher jtescher force-pushed the nav-clear-search-box branch from 41d162b to 145bafb Compare November 19, 2019 01:03
@jtescher
Copy link
Contributor Author

@carols10cents ok great! rebased, now explicitly setting the searchQuery both index and search seems to fix the issues you were bringing up. When I run this locally I can now navigate back and forward and the search terms are as expected. Navigating through clicking top left clears the query, also reloading the page at any point does not mess things up.

Let me know if there are other things you'd like to see here 👍

@carols10cents
Copy link
Member

Awesome!!! This looks great, thank you so much!

I tested this in Firefox, Chrome, and Safari and it's working as I would expect. Firefox Nightly sometimes is only changing the URL and not the page when I navigate back, but I expect it'll work tomorrow 😆

@bors r+

@bors
Copy link
Contributor

bors commented Nov 20, 2019

📌 Commit 145bafb has been approved by carols10cents

@bors
Copy link
Contributor

bors commented Nov 20, 2019

⌛ Testing commit 145bafb with merge 36cfbe3...

bors added a commit that referenced this pull request Nov 20, 2019
Clear search input on index route

Not sure what the correct product choice is here, but this clears the search input when navigating back to index route if that is in fact the behavior that is preferred.

Fixes #1230

(for some context both npm and rubygems.org do NOT clear the index if you search and then navigate back via browser, but both clear if you navigate forward to the index route via top left icon clicks)
@bors
Copy link
Contributor

bors commented Nov 20, 2019

☀️ Test successful - checks-travis
Approved by: carols10cents
Pushing 36cfbe3 to master...

@bors bors merged commit 145bafb into rust-lang:master Nov 20, 2019
@jtescher jtescher deleted the nav-clear-search-box branch November 21, 2019 01:03
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.

Search field not cleared back when going back into history
4 participants