Fix corner cases when dealing with mobile mode · rust-lang/rust@9566db1 (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1560,6 +1560,9 @@ a.tooltip:hover::after { | ||
1560 | 1560 | left: 8px; |
1561 | 1561 | z-index: 101; |
1562 | 1562 | } |
1563 | +.hide-sidebar .src #sidebar-button { | |
1564 | +position: static; | |
1565 | +} | |
1563 | 1566 | #settings-menu > a, #help-button > a, #sidebar-button > a { |
1564 | 1567 | display: flex; |
1565 | 1568 | align-items: center; |
@@ -1896,6 +1899,12 @@ in src-script.js and main.js | ||
1896 | 1899 | .src .search-form { |
1897 | 1900 | margin-left: 40px; |
1898 | 1901 | } |
1902 | + .hide-sidebar .search-form { | |
1903 | +margin-left: 32px; | |
1904 | + } | |
1905 | + .hide-sidebar .src .search-form { | |
1906 | +margin-left: 0; | |
1907 | + } | |
1899 | 1908 | |
1900 | 1909 | .sidebar.shown, |
1901 | 1910 | .src-sidebar-expanded .src .sidebar, |
@@ -2020,12 +2029,6 @@ in src-script.js and main.js | ||
2020 | 2029 | .src .src-sidebar-title { |
2021 | 2030 | padding-top: 0; |
2022 | 2031 | } |
2023 | - .hide-sidebar #sidebar-button { | |
2024 | -position: static; | |
2025 | - } | |
2026 | - .src #sidebar-button { | |
2027 | -position: fixed; | |
2028 | - } | |
2029 | 2032 | |
2030 | 2033 | /* Position of the "[-]" element. */ |
2031 | 2034 | details.toggle:not(.top-doc) > summary { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1519,18 +1519,14 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm | ||
1519 | 1519 | // and it can be activated by resizing the sidebar into nothing. |
1520 | 1520 | const sidebarButton = document.getElementById("sidebar-button"); |
1521 | 1521 | if (sidebarButton) { |
1522 | -if (document.querySelector(".rustdoc.src")) { | |
1523 | -sidebarButton.addEventListener("click", e => { | |
1522 | +sidebarButton.addEventListener("click", e => { | |
1523 | +removeClass(document.documentElement, "hide-sidebar"); | |
1524 | +updateLocalStorage("hide-sidebar", "false"); | |
1525 | +if (document.querySelector(".rustdoc.src")) { | |
1524 | 1526 | window.rustdocToggleSrcSidebar(); |
1525 | -e.preventDefault(); | |
1526 | -}); | |
1527 | -} else { | |
1528 | -sidebarButton.addEventListener("click", e => { | |
1529 | -removeClass(document.documentElement, "hide-sidebar"); | |
1530 | -updateLocalStorage("hide-sidebar", "false"); | |
1531 | -e.preventDefault(); | |
1532 | -}); | |
1533 | -} | |
1527 | +} | |
1528 | +e.preventDefault(); | |
1529 | +}); | |
1534 | 1530 | } |
1535 | 1531 | |
1536 | 1532 | // Pointer capture. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,3 +21,31 @@ wait-for-css: ("#settings", {"display": "block"}) | ||
21 | 21 | assert-property: ("#hide-sidebar", {"checked": "true"}) |
22 | 22 | click: "#hide-sidebar" |
23 | 23 | wait-for-css: (".sidebar", {"display": "block"}) |
24 | + | |
25 | +// Verify that hiding the sidebar hides the source sidebar | |
26 | +// and puts the button in static position mode on mobile | |
27 | +go-to: "file://" + |DOC_PATH | |
28 | +set-window-size: (600, 600) | |
29 | +focus: "#settings-menu a" | |
30 | +press-key: "Enter" | |
31 | +wait-for-css: ("#settings", {"display": "block"}) | |
32 | +wait-for-css: ("#sidebar-button", {"position": "fixed"}) | |
33 | +store-position: ("#sidebar-button", { | |
34 | + "y": sidebar_button_y, | |
35 | + "x": sidebar_button_x, | |
36 | +}) | |
37 | +assert-property: ("#hide-sidebar", {"checked": "false"}) | |
38 | +click: "#hide-sidebar" | |
39 | +wait-for-css: (".sidebar", {"display": "none"}) | |
40 | +wait-for-css: ("#sidebar-button", {"position": "static"}) | |
41 | +assert-position: ("#sidebar-button", { | |
42 | + "y": |sidebar_button_y | |
43 | + "x": |sidebar_button_x | |
44 | +}) | |
45 | +assert-property: ("#hide-sidebar", {"checked": "true"}) | |
46 | +press-key: "Escape" | |
47 | +// Clicking the sidebar button should work, and implicitly re-enable | |
48 | +// the persistent navigation bar | |
49 | +wait-for-css: ("#settings", {"display": "none"}) | |
50 | +click: "#sidebar-button" | |
51 | +wait-for-css: (".sidebar", {"display": "block"}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,6 +18,7 @@ | ||
18 | 18 | --code-attribute-color: #999; |
19 | 19 | --toggles-color: #999; |
20 | 20 | --toggle-filter: none; |
21 | +--mobile-sidebar-menu-filter: none; | |
21 | 22 | --search-input-focused-border-color: #66afe9; |
22 | 23 | --copy-path-button-color: #999; |
23 | 24 | --copy-path-img-filter: invert(50%); |