-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
rustdoc: Fix events not being registered when navigating browser history #95674
rustdoc: Fix events not being registered when navigating browser history #95674
Conversation
Some changes occurred in HTML/CSS/JS. |
This comment has been minimized.
This comment has been minimized.
3d488d8
to
e0d1dfc
Compare
I uploaded an online version as well here. |
Are you able to provide more detail about those cases? Do they happen when you've navigated backwards or forwards to a search page? I tried to reproduce on Firefox and could not.
This is surprising. If none of the search events were registered, how would hitting Enter trigger a search?
I doubt it. When navigating forward and back, we use the back-forward cache (bfcache). That cache preserves page JS state. That cache also preserves form state like search fields. However, our search field has
So we re-run the search function in order to copy the query from the URL into the search box (we can likely be much more efficient here, by just copying the query and not re-searching). So the bfcache issue shouldn't cause us to be missing event handlers after a back navigation. |
I can reproduce it every time with:
I discovered it the first time after waking up my computer. |
Weird; I can't reproduce on Firefox 99.0, Ubuntu. On either stable or nightly on doc.rust-lang.org. Does this reproduce for you in a fresh profile? What version of Firefox? |
Firefox 99 on ubuntu. Default profile (so "stable" I assume). |
By "stable" I meant https://doc.rust-lang.org/std (as opposed to https://doc.rust-lang.org/nightly/std). Does it reproduce on both for you? By "fresh profile" I meant: if you run |
I have the problem on stable, beta and nightly. I'll need to check with the firefox profile you provided. |
When running with
Did you try after a computer sleep wake up? |
☔ The latest upstream changes (presumably #96428) made this pull request unmergeable. Please resolve the merge conflicts. |
That's odd. Try this instead:
Yes. |
Didn't have time to come back to this but I found a weird case to "fix" this: resizing the viewport. |
@GuillaumeGomez FYI: when a PR is ready for review, send a message containing |
I got some more information about this. Here's a scenario which allows me to repeat this bug every time (on firefox, linux):
What's interesting is that when I look at the events registered on the |
It might be linked to #93784.
I realized lately that in some cases, I needed to press ENTER for the rustdoc search to be performed on firefox. After inspecting the DOM events, I saw that the rustdoc events were simply not registered, meaning the
registerSearchEvents
needed to be run (again?). I suspect it's the same issue that forces us to call thesearch
function for firefox when we navigate through history.I created new functions where we use
addEventListener
to prevent to register a same event more than once by first removing it by usingremoveEventListener
.You can test it online here.
r? @jsha