Skip to content
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

Improve the page title switch handling between search and doc #78921

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Nov 10, 2020

The current behavior often "forgets" to update the page title when discarding/putting back the search results. This isn't optimal which is why I wrote this fix.

r? @jyn514

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 10, 2020
@@ -113,6 +113,7 @@ function defocusSearchBar() {
var mouseMovedAfterSearch = true;

var titleBeforeSearch = document.title;
var searchTitle = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need another variable? Why not just directly modify document.title?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do, but it's simpler in case we come back to the search instead of regenerate it once again.

@jyn514 jyn514 added A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 10, 2020
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

The idea looks good, just a question about the implementation.

@@ -2736,6 +2738,7 @@ function defocusSearchBar() {
"",
"?search=" + encodeURIComponent(search_input.value));
}
document.title = searchTitle;
Copy link
Member

Choose a reason for hiding this comment

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

When does putBackSearch run? Are you sure search() will be run before?

Copy link
Member Author

Choose a reason for hiding this comment

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

putBackSearch is run when you focus the search input and it's not empty. Meaning that the search already ran at this point. ;)

@jyn514
Copy link
Member

jyn514 commented Nov 12, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 12, 2020

📌 Commit 46c921d has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2020
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 12, 2020
… r=jyn514

Improve the page title switch handling between search and doc

The current behavior often "forgets" to update the page title when discarding/putting back the search results. This isn't optimal which is why I wrote this fix.

r? `@jyn514`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2020
…laumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#78916 (extend const generics test suite)
 - rust-lang#78921 (Improve the page title switch handling between search and doc)
 - rust-lang#78933 (Don't print thread ids and names in `tracing` logs)
 - rust-lang#78960 (Test default values for const parameters.)
 - rust-lang#78971 (Update books)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6d41735 into rust-lang:master Nov 12, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 12, 2020
@GuillaumeGomez GuillaumeGomez deleted the search-result-title branch November 12, 2020 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants