Skip to content

Commit 045ac21

Browse files
authored
Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=GuillaumeGomez
rustdoc: on mobile, make the sidebar full width and linewrap this is because the mobile sidebar cannot be resized, unlike on desktop.
2 parents 3d86494 + bcca611 commit 045ac21

File tree

4 files changed

+12
-20
lines changed

4 files changed

+12
-20
lines changed

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,9 +2527,12 @@ in src-script.js and main.js
25272527
z-index: 11;
25282528
/* Reduce height slightly to account for mobile topbar. */
25292529
height: calc(100vh - 45px);
2530-
width: 200px;
25312530
/* resize indicator: hide this when on touch or mobile */
25322531
border-right: none;
2532+
width: 100%;
2533+
}
2534+
.sidebar-elems .block li a {
2535+
white-space: wrap;
25332536
}
25342537

25352538
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,

tests/rustdoc-gui/notable-trait.goml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ click: ".sidebar-menu-toggle"
244244
assert: "//*[@class='sidebar shown']"
245245
assert-count: ("//*[@class='tooltip popover']", 0)
246246
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
247-
// Clicking a notable trait tooltip popover should close the sidebar.
248-
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
249-
assert-count: ("//*[@class='tooltip popover']", 1)
250-
assert-false: "//*[@class='sidebar shown']"
251247

252248
// Also check the focus handling for the settings button.
253249
set-window-size: (1100, 600)

tests/rustdoc-gui/pocket-menu.goml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,3 @@ assert-css: ("#settings-menu .popover", {"display": "block"})
6868
click: ".sidebar-menu-toggle"
6969
assert: "//*[@class='sidebar shown']"
7070
assert-css: ("#settings-menu .popover", {"display": "none"})
71-
// Opening the settings popover should close the sidebar.
72-
click: "#settings-menu a"
73-
assert-css: ("#settings-menu .popover", {"display": "block"})
74-
assert-false: "//*[@class='sidebar shown']"
75-
76-
// Opening the settings popover at start (which async loads stuff) should also close.
77-
reload:
78-
click: ".sidebar-menu-toggle"
79-
assert: "//*[@class='sidebar shown']"
80-
assert-false: "#settings-menu .popover"
81-
click: "#settings-menu a"
82-
assert-false: "//*[@class='sidebar shown']"
83-
wait-for: "#settings-menu .popover"

tests/rustdoc-gui/sidebar-mobile.goml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ assert-css: (
3232
{"display": "block"}
3333
)
3434

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

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

5959
// Now checking the background color of the sidebar.
60+
// Close the sidebar menu.
61+
press-key: "Escape"
6062
show-text: true
6163

6264
define-function: (
@@ -72,6 +74,10 @@ define-function: (
7274
"background-color": |background|,
7375
"color": |color|,
7476
})
77+
// Make sure the sidebar is full width
78+
compare-elements-size: (".sidebar", "body", ["width"])
79+
// Close the sidebar menu.
80+
press-key: "Escape"
7581
},
7682
)
7783

0 commit comments

Comments
 (0)