about summary refs log tree commit diff
path: root/src/test/rustdoc-gui/sidebar-source-code-display.goml
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-07-01 12:13:46 -0700
committerMichael Howell <michael@notriddle.com>2022-07-01 14:33:34 -0700
commit83f22885ae9fe7116f97efd7f7df9b6a719d7e6f (patch)
treec74cac98749540dc40d78236f1789ddc413f28dd /src/test/rustdoc-gui/sidebar-source-code-display.goml
parent5b9775fe17893cba641a071de7e0a7c8f478c41b (diff)
Improve click behavior of the source code mobile full-screen "sidebar"
On desktop, if you open the source code sidebar, it stays open even when you
move from page to page. It used to do the same thing on mobile, but I think
that's stupid. Since the file list fills the entire screen on mobile, and you
can't really do anything with the currently selected file other than dismiss
the "sidebar" to look at it, it's safe to assume that anybody who clicks a
file in that list probably wants the list to go away so they can see it.
Diffstat (limited to 'src/test/rustdoc-gui/sidebar-source-code-display.goml')
-rw-r--r--src/test/rustdoc-gui/sidebar-source-code-display.goml22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/rustdoc-gui/sidebar-source-code-display.goml b/src/test/rustdoc-gui/sidebar-source-code-display.goml
index c441f84a821..7728bfd025f 100644
--- a/src/test/rustdoc-gui/sidebar-source-code-display.goml
+++ b/src/test/rustdoc-gui/sidebar-source-code-display.goml
@@ -18,6 +18,16 @@ click: "#sidebar-toggle"
 // Because of the transition CSS, we check by using `wait-for-css` instead of `assert-css`.
 wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})
 
+// We now check that opening the sidebar and clicking a link will leave it open.
+// The behavior here on desktop is different than the behavior on mobile,
+// but since the sidebar doesn't fill the entire screen here, it makes sense to have the
+// sidebar stay resident.
+wait-for-css: (".sidebar", {"width": "300px"})
+assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
+click: ".sidebar a.selected"
+goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
+assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
+
 // Now we check the display of the sidebar items.
 show-text: true
 
@@ -152,3 +162,15 @@ click: "#sidebar-toggle"
 wait-for-css: (".sidebar", {"width": "0px"})
 // The "scrollTop" property should be the same.
 assert-window-property: {"pageYOffset": "2519"}
+
+// We now check that opening the sidebar and clicking a link will close it.
+// The behavior here on mobile is different than the behavior on desktop,
+// but common sense dictates that if you have a list of files that fills the entire screen, and
+// you click one of them, you probably want to actually see the file's contents, and not just
+// make it the current selection.
+click: "#sidebar-toggle"
+wait-for-css: (".sidebar", {"width": "500px"})
+assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
+click: ".sidebar a.selected"
+goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
+assert-local-storage: {"rustdoc-source-sidebar-show": "false"}