-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix navbar click while in a search #45812
Conversation
Some changes occurred in HTML/CSS. |
r? @frewsxcv (rust_highfive has picked a reviewer for you, use r? to override) |
This does not fix the issue. The URL still swallows the |
57e0d15
to
3533b2a
Compare
3533b2a
to
acd5e8c
Compare
So with the current change, the search properly works, and clicking a link in the sidebar will properly dismiss the search, scroll to the desired heading, and toggle the heading's "active" highlight (giving it the yellow background). However, something strange happens: The window title is not changed back from "Results for (query)", and the URL will only say |
not too familiar with this code, so gonna reassign |
Updated. |
Is it possible to clear out the query parameters when setting the hash? The URL now properly has the hash, but it still has the query parameters, so now it has Also the title doesn't get set back when you click a sidebar link, so it still says "Results for sync" even though the search results were dismissed. |
src/librustdoc/html/static/main.js
Outdated
removeClass(document.getElementById("main"), "hidden"); | ||
var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1); | ||
if (browserSupportsHistoryApi()) { | ||
history.replaceState(hash, "std - Rust", "?search=#" + hash); |
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.
- Firefox ignores the title argument to
pushState
/replaceState
anyway, so right now this is moot, but: - Setting this unilaterally to "std - Rust" is wildly inaccurate, even within libstd, because for anything but the crate root the title is set to the path of the item. But for anything but libstd, this is just erroneous.
On the other hand, with the empty search param, the link is now stable, and the search box and results are still the same. If we can't change the title (in Firefox, at least) via replaceState
, then i'll just give up on it for the time being. I'd suggest either finding some other way to set it properly or just changing this back to ""
.
1157788
to
0d89899
Compare
With the last force-push, i'm ready to call it. There's still the issue of the page title being wrong, but at this point i'm willing to cut my losses. r=me pending travis. |
Actually, the JS doesn't affect any of the tests that i know of, and it passed tidy, so let's just move along. @bors r+ rollup |
📌 Commit 0d89899 has been approved by |
…QuietMisdreavus Fix navbar click while in a search Fixes rust-lang#45790.
Fixes #45790.