Skip to content

Commit 7eac19c

Browse files
committed
Auto merge of rust-lang#94320 - GuillaumeGomez:sidebar-display, r=jsha
Fix sidebar elements display The bug can be seen more easily when the javascript is disabled: ![Screenshot from 2022-02-24 12-18-28](https://user-images.githubusercontent.com/3050060/155514578-cbefd3dd-f006-47e9-bc76-7c26d7e823e8.png) r? `@jsha`
2 parents 617e8c7 + db34320 commit 7eac19c

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,17 @@ nav.sub {
397397
overflow-y: hidden;
398398
}
399399

400-
.source .sidebar > *:not(:first-child) {
401-
transition: opacity 0.5s;
400+
.source .sidebar > *:not(#sidebar-toggle) {
402401
opacity: 0;
403402
visibility: hidden;
403+
transition: opacity 0.5s;
404404
}
405405

406406
.source .sidebar.expanded {
407407
overflow-y: auto;
408408
}
409409

410-
.source .sidebar.expanded > * {
410+
.source .sidebar.expanded > *:not(#sidebar-toggle) {
411411
opacity: 1;
412412
visibility: visible;
413413
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This test ensures that the elements in the sidebar are displayed correctly.
2+
javascript: false
3+
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
4+
// Since the javascript is disabled, there shouldn't be a toggle.
5+
assert-false: "#sidebar-toggle"
6+
// For some reason, we need to wait a bit here because it seems like the transition on opacity
7+
// is being applied whereas it can't be reproduced in a browser...
8+
wait-for: 500
9+
assert-css: (".sidebar > *", {"visibility": "hidden", "opacity": 0})
10+
11+
// Let's retry with javascript enabled.
12+
javascript: true
13+
reload:
14+
wait-for: "#sidebar-toggle"
15+
assert-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
16+
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "hidden", "opacity": 0})
17+
// Let's expand the sidebar now.
18+
click: "#sidebar-toggle"
19+
// Because of the transition CSS, better wait a second before checking.
20+
wait-for: 1000
21+
assert-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
22+
assert-css: (".sidebar > *:not(#sidebar-toggle)", {"visibility": "visible", "opacity": 1})

0 commit comments

Comments
 (0)