Skip to content

rustdoc: web: don't reset the search bar #12439

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
Feb 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly I don't think JS has quite adopted rust syntax just yet :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah crap

On Sat, Feb 22, 2014 at 3:24 PM, Alex Crichton [email protected]:

In src/librustdoc/html/static/main.js:

@@ -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 {
    

Sadly I don't think JS has quite adopted rust syntax just yet :(


Reply to this email directly or view it on GitHubhttps://github.com//pull/12439/files#r9972844
.

$('.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.
Expand Down