Skip to content

rustdoc: on mobile, make the sidebar full width and linewrap #139831

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

Merged
merged 3 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2527,9 +2527,12 @@ in src-script.js and main.js
z-index: 11;
/* Reduce height slightly to account for mobile topbar. */
height: calc(100vh - 45px);
width: 200px;
/* resize indicator: hide this when on touch or mobile */
border-right: none;
width: 100%;
}
.sidebar-elems .block li a {
white-space: wrap;
}

/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
Expand Down
4 changes: 0 additions & 4 deletions tests/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ click: ".sidebar-menu-toggle"
assert: "//*[@class='sidebar shown']"
assert-count: ("//*[@class='tooltip popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
// Clicking a notable trait tooltip popover should close the sidebar.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
assert-count: ("//*[@class='tooltip popover']", 1)
assert-false: "//*[@class='sidebar shown']"

// Also check the focus handling for the settings button.
set-window-size: (1100, 600)
Expand Down
13 changes: 0 additions & 13 deletions tests/rustdoc-gui/pocket-menu.goml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,3 @@ assert-css: ("#settings-menu .popover", {"display": "block"})
click: ".sidebar-menu-toggle"
assert: "//*[@class='sidebar shown']"
assert-css: ("#settings-menu .popover", {"display": "none"})
// Opening the settings popover should close the sidebar.
click: "#settings-menu a"
assert-css: ("#settings-menu .popover", {"display": "block"})
assert-false: "//*[@class='sidebar shown']"

// Opening the settings popover at start (which async loads stuff) should also close.
reload:
click: ".sidebar-menu-toggle"
assert: "//*[@class='sidebar shown']"
assert-false: "#settings-menu .popover"
click: "#settings-menu a"
assert-false: "//*[@class='sidebar shown']"
wait-for: "#settings-menu .popover"
10 changes: 8 additions & 2 deletions tests/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ assert-css: (
{"display": "block"}
)

// Click elsewhere.
click: "body"
// Click the toggle to close it
click: ".sidebar-menu-toggle"
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})

// Open the sidebar menu, and make sure pressing Escape closes it.
Expand All @@ -57,6 +57,8 @@ scroll-to: ".block.keyword li:nth-child(1)"
compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 544})

// Now checking the background color of the sidebar.
// Close the sidebar menu.
press-key: "Escape"
show-text: true

define-function: (
Expand All @@ -72,6 +74,10 @@ define-function: (
"background-color": |background|,
"color": |color|,
})
// Make sure the sidebar is full width
compare-elements-size: (".sidebar", "body", ["width"])
// Close the sidebar menu.
press-key: "Escape"
},
)

Expand Down
Loading