From 5326fc9bc78ca44e04d4583a8ced3a23768815e6 Mon Sep 17 00:00:00 2001 From: binarycat Date: Mon, 14 Apr 2025 19:01:38 -0500 Subject: [PATCH 1/3] rustdoc: on mobile, make the sidebar full width and linewrap this is because the mobile sidebar cannot be resized, unlike on desktop. --- src/librustdoc/html/static/css/rustdoc.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index a81d5c9c49b4b..7be83b65fbfaf 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -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, From 1eba1b56e33f196e6b48cad2efb41b9b9ab7452f Mon Sep 17 00:00:00 2001 From: binarycat Date: Thu, 22 May 2025 16:05:52 -0500 Subject: [PATCH 2/3] rustdoc: rip out all the gui tests for <100% width mobile sidebar stuff like "clicking the settings menu closes the mobile sidebar" is now impossible for users to observe, since the mobile sidebar will always cover the settings menu due to being full-width, which is good because that behavior is also now impossible for our testing framework to observe. --- tests/rustdoc-gui/notable-trait.goml | 4 ---- tests/rustdoc-gui/pocket-menu.goml | 13 ------------- tests/rustdoc-gui/sidebar-mobile.goml | 7 +++++-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 4624fb80b3779..7fc70e0675df4 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -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) diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml index 4a062fec7516d..073172dd8a791 100644 --- a/tests/rustdoc-gui/pocket-menu.goml +++ b/tests/rustdoc-gui/pocket-menu.goml @@ -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" diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 4ada4837a5774..0596f84317481 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -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. @@ -57,6 +57,7 @@ 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. +reload: show-text: true define-function: ( @@ -72,6 +73,8 @@ define-function: ( "background-color": |background|, "color": |color|, }) + // Close the sidebar menu. + press-key: "Escape" }, ) From bcca611b359c74b71e798c2ee30f4695c6218bbf Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 23 May 2025 17:43:19 -0500 Subject: [PATCH 3/3] rustdoc-gui test: apply suggestions from code review --- tests/rustdoc-gui/sidebar-mobile.goml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/sidebar-mobile.goml b/tests/rustdoc-gui/sidebar-mobile.goml index 0596f84317481..6ddc07c6481c1 100644 --- a/tests/rustdoc-gui/sidebar-mobile.goml +++ b/tests/rustdoc-gui/sidebar-mobile.goml @@ -57,7 +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. -reload: +// Close the sidebar menu. +press-key: "Escape" show-text: true define-function: ( @@ -73,6 +74,8 @@ 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" },