-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: improve click behavior of the source code mobile full-screen "sidebar" #98776
rustdoc: improve click behavior of the source code mobile full-screen "sidebar" #98776
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @Folyd, @jsha |
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
9ae57a4
to
d7141da
Compare
@@ -48,6 54,7 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) { | |||
const file = document.createElement("a"); | |||
file.innerText = file_text; | |||
file.href = rootPath "src/" fullPath file_text ".html"; | |||
file.addEventListener("click", closeSidebarIfMobile); |
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.
Instead of doing this, wouldn't it be simpler to not open the sidebar by default when we arrive on a new page with a "mobile width"?
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.
That would be possible, but it would open up the following, very weird timeline:
- A user with a 7-inch Android tablet in portrait mode clicks open the sidebar. The sidebar is now open, and
rustdoc-source-sidebar-show == "true"
. - The user clicks a link. The sidebar is now closed, but
rustdoc-source-sidebar-show == "true"
. - The user rotates their tablet into landscape mode. The sidebar is still closed, but
rustdoc-source-sidebar-show == "true"
. - The user clicks an inline jump to definition link.
- The sidebar pops open, seemingly out of nowhere. This is bad.
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.
That makes sense indeed. Can you add a test where we check that a "resize" in-between won't re-open the sidebar as you mentioned?
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.
Okay, I've pushed commit 6e2c49f adding a test case for this.
This is a very good point! I think we can simplify it a bit by just not opening the sidebar when we arrive on a new page and we have a "mobile width". |
On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it.
d7141da
to
83f2288
Compare
Thanks! @bors r rollup |
📌 Commit 6e2c49f has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#97712 (ptr::copy and ptr::swap are doing untyped copies) - rust-lang#98624 (lints: mostly translatable diagnostics) - rust-lang#98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar") - rust-lang#98856 (Remove FIXME from rustdoc intra-doc test) - rust-lang#98913 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it.
Split out separately from #98772