about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-04-28 17:32:00 -0700
committerbors <bors@rust-lang.org>2014-04-28 17:32:00 -0700
commita72a6ec897e1b8d7e125be9bb4b60d89c79aa4c0 (patch)
treede1e8088d4ecfb6884823e5f141eb966871213ad
parent3cd6c1e008ac0696cedf6be68a4fa9d7b16550bf (diff)
parent5b2e4776296a23cc6429838e8ba47c3d42513004 (diff)
downloadrust-a72a6ec897e1b8d7e125be9bb4b60d89c79aa4c0.tar.gz
rust-a72a6ec897e1b8d7e125be9bb4b60d89c79aa4c0.zip
auto merge of #13830 : noamraph/rust/doc-browser-history, r=kballard
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.
-rw-r--r--src/librustdoc/html/static/main.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index e975fac6ed7..21d57a17c67 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -605,11 +605,10 @@
                     // cleared to ensure the search is successful.
                     currentResults = null;
                     // Synchronize search bar with query string state and
-                    // perform the search, but don't empty the bar if there's
-                    // nothing there.
-                    if (params.search !== undefined) {
-                        $('.search-input').val(params.search);
-                    }
+                    // perform the search. This will empty the bar if there's
+                    // nothing there, which lets you really go back to a
+                    // previous state with nothing in the bar.
+                    $('.search-input').val(params.search);
                     // Some browsers fire 'onpopstate' for every page load
                     // (Chrome), while others fire the event only when actually
                     // popping a state (Firefox), which is why search() is