about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustdoc/html/static/main.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 2abc8f7eb6a..150b083219b 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -150,6 +150,9 @@
             addClass(search, "hidden");
             removeClass(document.getElementById("main"), "hidden");
             var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
+            if (browserSupportsHistoryApi()) {
+                history.replaceState(hash, "", "#" + hash);
+            }
             var elem = document.getElementById(hash);
             if (elem) {
                 elem.scrollIntoView();
@@ -1560,6 +1563,17 @@
             });
         }
     });
+
+    var search_input = document.getElementsByClassName("search-input")[0];
+
+    if (search_input) {
+        search_input.onfocus = function() {
+            if (search.value !== "") {
+                addClass(document.getElementById("main"), "hidden");
+                removeClass(document.getElementById("search"), "hidden");
+            }
+        };
+    }
 }());
 
 // Sets the focus on the search bar at the top of the page