-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
Some changes occurred in HTML/CSS/JS. |
@@ -113,6 +113,7 @@ function defocusSearchBar() { | |||
var mouseMovedAfterSearch = true; | |||
|
|||
var titleBeforeSearch = document.title; | |||
var searchTitle = null; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. ;)
@bors r+ rollup |
📌 Commit 46c921d has been approved by |
… 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`
…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
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