about summary refs log tree commit diff
path: root/src/librustdoc/html/static
diff options
context:
space:
mode:
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-01-11 18:27:44 -0800
committerJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-01-17 12:01:35 -0800
commitb71f1fb0027cf49909d8597fcc90a77d5f573cc3 (patch)
treec75adb3b42fe251979f062d197ed0e7f2ef1bf99 /src/librustdoc/html/static
parentee5d8d37baaf5b5a81a98396952839c73ae41c68 (diff)
downloadrust-b71f1fb0027cf49909d8597fcc90a77d5f573cc3.tar.gz
rust-b71f1fb0027cf49909d8597fcc90a77d5f573cc3.zip
Hide mobile sidebar on some clicks
When the user clicks outside the sidebar, the sidebar should close.
Also, when the user clicks an internal link in the sidebar, it should
close.
Diffstat (limited to 'src/librustdoc/html/static')
-rw-r--r--src/librustdoc/html/static/js/main.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index f41c1bd817a..3acd1ccd4ce 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -897,6 +897,9 @@ function hideThemeButtonState() {
     handleClick("help-button", function(ev) {
         displayHelp(true, ev);
     });
+    handleClick(MAIN_ID, function() {
+        hideSidebar();
+    });
 
     onEachLazy(document.getElementsByTagName("a"), function(el) {
         // For clicks on internal links (<A> tags with a hash property), we expand the section we're
@@ -905,6 +908,7 @@ function hideThemeButtonState() {
         if (el.hash) {
             el.addEventListener("click", function() {
                 expandSection(el.hash.slice(1));
+                hideSidebar();
             });
         }
     });