From c3c4b9ead6f12cfcddcd081b47826d59338195fb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 15 Jul 2021 22:06:53 +0200 Subject: [PATCH 1/2] Do not hide the sidebar on mobile, move it outside of the viewport instead --- src/librustdoc/html/static/css/rustdoc.css | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 208e8f723f407..9e3ad66753133 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1631,15 +1631,18 @@ details.undocumented[open] > summary::before { display: none; } + /* We do NOT hide this element so that alternative device readers still have this information + available. */ .sidebar-elems { position: fixed; z-index: 1; - left: 0; top: 45px; bottom: 0; + width: 246px; + /* We move the sidebar to the left by its own width so it doesn't appear. */ + left: -246px; overflow-y: auto; border-right: 1px solid; - display: none; } .sidebar > .block.version { @@ -1727,8 +1730,7 @@ details.undocumented[open] > summary::before { } .show-it { - display: block; - width: 246px; + left: 0; } .show-it > .block.items { From 868ffd03ed2b52d23eeaa9bf48857dde5083c18d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 15 Jul 2021 22:12:28 +0200 Subject: [PATCH 2/2] Add test for sidebar display value on mobile --- src/test/rustdoc-gui/sidebar-mobile.goml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/test/rustdoc-gui/sidebar-mobile.goml diff --git a/src/test/rustdoc-gui/sidebar-mobile.goml b/src/test/rustdoc-gui/sidebar-mobile.goml new file mode 100644 index 0000000000000..9a1442e48a9ea --- /dev/null +++ b/src/test/rustdoc-gui/sidebar-mobile.goml @@ -0,0 +1,10 @@ +// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport. +// This is especially important for devices for "text-first" content (like for users with +// sight issues). +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +// Switching to "mobile view" by reducing the width to 600px. +size: (600, 600) +assert-css: (".sidebar-elems", {"display": "block", "left": "-246px"}) +// Opening the sidebar menu. +click: ".sidebar-menu" +assert-css: (".sidebar-elems", {"display": "block", "left": "0px"})