diff options
| author | bors <bors@rust-lang.org> | 2014-02-22 07:56:47 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-22 07:56:47 -0800 |
| commit | 52755b717ead712d27eaa554b7eea78e3d181cee (patch) | |
| tree | 8d0a0b8133be3190ec03b66e3584e20dd3596caf | |
| parent | 51676b21d63ee427be862b1f8112def790cd57a4 (diff) | |
| parent | c9713ffe81e0eea4de3745ce039dd170b13e54e3 (diff) | |
| download | rust-52755b717ead712d27eaa554b7eea78e3d181cee.tar.gz rust-52755b717ead712d27eaa554b7eea78e3d181cee.zip | |
auto merge of #12439 : cmr/rust/rustdoc-reset, r=thestinger
rustdoc: web: don't reset the search bar
| -rw-r--r-- | src/librustdoc/html/static/main.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 6dbf56681bd..92cad51200e 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -114,8 +114,13 @@ function initSearch(searchIndex) { var currentResults, index, params = getQueryStringParams(); - // Populate search bar with query string search term when provided. - $(".search-input")[0].value = params.search || ''; + // Populate search bar with query string search term when provided, + // but only if the input bar is empty. This avoid the obnoxious issue + // where you start trying to do a search, and the index loads, and + // suddenly your search is gone! + if ($(".search-input")[0].value === "") { + $(".search-input")[0].value = params.search || ''; + } /** * Executes the query and builds an index of results @@ -574,8 +579,12 @@ // When browsing forward to search results the previous search will be repeated, // so the currentResults are cleared to ensure the search is successful. currentResults = null; - // Synchronize search bar with query string state and perform the search. - $('.search-input').val(params.search); + // 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); + } // 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 called // both here and at the end of the startSearch() function. |
