Skip to content

rustdoc: Make going back in browser history work after typing a search term #13830

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
Apr 29, 2014

Conversation

noamraph
Copy link
Contributor

Currently, in both chrome and firefox, if I type something in the search box in the reference docs I get immediately the search results. That's great. However, if I want to go back to the doc I was reading and try to press the back button, I am immediately forwarded again to the search results. This is caused by the fact that the search term is (deliberately) left in the search box, and the search() function is called as if I typed the search term again.
I disabled calling the search() function if there's no search term in the URL, and now it seems to work fine.

I hope I'm sending the pull request correctly - I'm not really used to git and github.

@lilyball
Copy link
Contributor

Why is the search term deliberately left in the search box? I would expect it to be removed. If there's a search term in the search box, I should be seeing the search results.

@noamraph
Copy link
Contributor Author

I don't really know, but a comment says "don't empty the bar if there's nothing there."
There's something nice about the search term being left in the search box because it reminds what was searched. I actually don't see a problem with it, since it seems that the search results only appear if the search term is being edited.

@lilyball
Copy link
Contributor

There's something nice about the search term being left in the search box because it reminds what was searched

That actually sounds like the complete opposite of correct behavior. If I want to see what I searched for I'll just hit Forward again. But the way the UI works right now, if there's something in the search field, then I should be seeing search results.

I see the comment you're referring to, but I think it's wrong. That comment should be removed and the code should be updated to clear the search box if there's no query parameter.

@noamraph
Copy link
Contributor Author

That's actually pretty easy - the "if" around $('.search-input').val(params.search); should just be removed. What should I do now? Should I create a new branch and a new pull request?

@lilyball
Copy link
Contributor

Make your changes, amend the original commit (git commit --amend can do it, or you can use git rebase --interactive to squash them), and force-push back to the same branch. That will update this PR with your new code. You should then comment on the PR so we know you force-pushed (GitHub doesn't send emails for force pushes).

@noamraph
Copy link
Contributor Author

Ok, I did exactly that.

bors added a commit that referenced this pull request Apr 29, 2014
Currently, in both chrome and firefox, if I type something in the search box in the reference docs I get immediately the search results. That's great. However, if I want to go back to the doc I was reading and try to press the back button, I am immediately forwarded again to the search results. This is caused by the fact that the search term is (deliberately) left in the search box, and the search() function is called as if I typed the search term again.
I disabled calling the search() function if there's no search term in the URL, and now it seems to work fine.

I hope I'm sending the pull request correctly - I'm not really used to git and github.
@bors bors closed this Apr 29, 2014
@bors bors merged commit 5b2e477 into rust-lang:master Apr 29, 2014
arcnmx pushed a commit to arcnmx/rust that referenced this pull request Jan 9, 2023
Minor manual cleanup

* use default derive
* use `strip_prefix` where possible to avoid dup work
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 26, 2024
…t-lang#13830)

fix rust-lang#12320

When there're multiple attributes, clippy suggests leaving an extra
comma and it makes an error.

changelog: [`must_use_unit`]: No longer make incorrect suggestions when
multiple attributes present.
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.

3 participants