diff options
| author | Michael Howell <michael@notriddle.com> | 2022-11-26 14:32:57 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-11-26 14:32:57 -0700 |
| commit | c26074afde3dbe5873874647709ccd4ce4b64813 (patch) | |
| tree | f9067931870867c2d2b8f0bf340fae288488990f | |
| parent | 74de78a414043202ed70c239b2aca74dceb4c1a8 (diff) | |
| download | rust-c26074afde3dbe5873874647709ccd4ce4b64813.tar.gz rust-c26074afde3dbe5873874647709ccd4ce4b64813.zip | |
rustdoc: pass "true" to reset focus for notable traits
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index ef1ae68c59e..7230df36c07 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -202,7 +202,7 @@ function loadCss(cssUrl) { if (event.ctrlKey || event.altKey || event.metaKey) { return; } - window.hideAllModals(); + window.hideAllModals(false); addClass(getSettingsButton(), "rotate"); event.preventDefault(); // Sending request for the CSS and the JS files at the same time so it will @@ -378,10 +378,7 @@ function loadCss(cssUrl) { } ev.preventDefault(); searchState.defocus(); - // If the notable traits popover is open, and the user presses Escape, - // reset focus back to the link. - hideNotable(true); - window.hideAllModals(); + window.hideAllModals(true); // true = reset focus for notable traits } function handleShortcut(ev) { @@ -771,7 +768,7 @@ function loadCss(cssUrl) { }; function showSidebar() { - window.hideAllModals(); + window.hideAllModals(false); window.rustdocMobileScrollLock(); const sidebar = document.getElementsByClassName("sidebar")[0]; addClass(sidebar, "shown"); @@ -848,7 +845,7 @@ function loadCss(cssUrl) { // Make this function idempotent. return; } - window.hideAllModals(); + window.hideAllModals(false); const ty = e.getAttribute("data-ty"); const wrapper = document.createElement("div"); wrapper.innerHTML = "<div class=\"docblock\">" + window.NOTABLE_TRAITS[ty] + "</div>"; @@ -1057,13 +1054,12 @@ function loadCss(cssUrl) { /** * Hide popover menus, notable trait tooltips, and the sidebar (if applicable). * - * This version does not do anything to tweak the focused element. The caller - * should make sure it behaves reasonably. + * Pass "true" to reset focus for notable traits. */ - window.hideAllModals = function() { + window.hideAllModals = function(switchFocus) { hideSidebar(); window.hidePopoverMenus(); - hideNotable(false); + hideNotable(switchFocus); }; /** |
