Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7f66914
Change multiline span ASCII art visual order
estebank Nov 23, 2022
d84cff7
Tweak output
estebank Nov 23, 2022
c256bd2
Remove redundant `all` in cfg
ChrisDenton Nov 26, 2022
2ab3f76
Remove more redundant `all`s
ChrisDenton Nov 26, 2022
e06b61c
explain how to get the discriminant out of a `#[repr(T)] enum`
Nov 25, 2022
4b2a1eb
Support unit tests for jsondoclint
aDotInTheVoid Nov 26, 2022
946d51e
fix broken link fragment
Nov 26, 2022
09818a8
Add a test that makes sense
aDotInTheVoid Nov 26, 2022
74de78a
rustdoc: improve popover focus handling JS
notriddle Nov 26, 2022
c26074a
rustdoc: pass "true" to reset focus for notable traits
notriddle Nov 26, 2022
2343353
Avoid ICE if the Clone trait is not found while building error sugges…
mucinoab Nov 26, 2022
353cef9
Use target exe_suffix for doctests
workingjubilee Apr 9, 2022
47ddca6
Attempt to solve problem with globs
workingjubilee Nov 27, 2022
db71df3
Rollup merge of #95836 - workingjubilee:doctest-exe, r=notriddle
matthiaskrgr Nov 27, 2022
e2111a6
Rollup merge of #104795 - estebank:multiline-spans, r=TaKO8Ki
matthiaskrgr Nov 27, 2022
28f60d5
Rollup merge of #104892 - lukas-code:discriminant, r=scottmcm
matthiaskrgr Nov 27, 2022
1b7e7a4
Rollup merge of #104934 - ChrisDenton:all-anybody-wants, r=thomcc
matthiaskrgr Nov 27, 2022
13fe0aa
Rollup merge of #104944 - aDotInTheVoid:jsondoclint-unit-tests, r=jyn514
matthiaskrgr Nov 27, 2022
112a6e2
Rollup merge of #104946 - notriddle:notriddle/popover-menu-focus, r=G…
matthiaskrgr Nov 27, 2022
4d62c79
Rollup merge of #104956 - mucinoab:issue-104870, r=compiler-errors
matthiaskrgr Nov 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ function loadCss(cssUrl) {
if (event.ctrlKey || event.altKey || event.metaKey) {
return;
}
window.hideAllModals(false);
addClass(getSettingsButton(), "rotate");
event.preventDefault();
// Sending request for the CSS and the JS files at the same time so it will
Expand Down Expand Up @@ -377,7 +378,7 @@ function loadCss(cssUrl) {
}
ev.preventDefault();
searchState.defocus();
window.hidePopoverMenus();
window.hideAllModals(true); // true = reset focus for notable traits
}

function handleShortcut(ev) {
Expand Down Expand Up @@ -767,6 +768,7 @@ function loadCss(cssUrl) {
};

function showSidebar() {
window.hideAllModals(false);
window.rustdocMobileScrollLock();
const sidebar = document.getElementsByClassName("sidebar")[0];
addClass(sidebar, "shown");
Expand Down Expand Up @@ -843,7 +845,7 @@ function loadCss(cssUrl) {
// Make this function idempotent.
return;
}
hideNotable(false);
window.hideAllModals(false);
const ty = e.getAttribute("data-ty");
const wrapper = document.createElement("div");
wrapper.innerHTML = "<div class=\"docblock\">" + window.NOTABLE_TRAITS[ty] + "</div>";
Expand Down Expand Up @@ -1049,14 +1051,24 @@ function loadCss(cssUrl) {
return container;
}

/**
* Hide popover menus, notable trait tooltips, and the sidebar (if applicable).
*
* Pass "true" to reset focus for notable traits.
*/
window.hideAllModals = function(switchFocus) {
hideSidebar();
window.hidePopoverMenus();
hideNotable(switchFocus);
};

/**
* Hide all the popover menus.
*/
window.hidePopoverMenus = function() {
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
elem.style.display = "none";
});
hideNotable(false);
};

/**
Expand All @@ -1081,7 +1093,7 @@ function loadCss(cssUrl) {
function showHelp() {
const menu = getHelpMenu(true);
if (menu.style.display === "none") {
window.hidePopoverMenus();
window.hideAllModals();
menu.style.display = "";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
event.preventDefault();
const shouldDisplaySettings = settingsMenu.style.display === "none";

window.hidePopoverMenus();
window.hideAllModals();
if (shouldDisplaySettings) {
displaySettings();
}
Expand Down
25 changes: 25 additions & 0 deletions src/test/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ move-cursor-to: "//*[@class='notable popover']"
assert-count: ("//*[@class='notable popover']", 1)
press-key: "Escape"
assert-count: ("//*[@class='notable popover']", 0)
assert: "#method\.create_an_iterator_from_read .notable-traits:focus"

// Check that clicking outside works.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable popover']", 1)
click: ".search-input"
assert-count: ("//*[@class='notable popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"

// Check that pressing tab over and over works.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
Expand Down Expand Up @@ -249,3 +251,26 @@ click: "#settings-menu a"
press-key: "Escape"
// We ensure we didn't come back to the previous focused item.
assert-window-property-false: {"scrollY": |scroll|}

// Opening the mobile sidebar should close the popover.
size: (650, 600)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable popover']", 1)
click: ".sidebar-menu-toggle"
assert: "//*[@class='sidebar shown']"
assert-count: ("//*[@class='notable popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
// Clicking a notable popover should close the sidebar.
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable popover']", 1)
assert-false: "//*[@class='sidebar shown']"

// Also check the focus handling for the help button.
size: (1100, 600)
reload:
assert-count: ("//*[@class='notable popover']", 0)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"
assert-count: ("//*[@class='notable popover']", 1)
click: "#help-button a"
assert-count: ("//*[@class='notable popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .notable-traits:focus"
21 changes: 21 additions & 0 deletions src/test/rustdoc-gui/pocket-menu.goml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,24 @@ assert-css: (
)
compare-elements-css: ("#help-button .popover", "#help-button .top", ["border-color"])
compare-elements-css: ("#help-button .popover", "#help-button .bottom", ["border-color"])

// Opening the mobile sidebar should close the settings popover.
size: (650, 600)
click: "#settings-menu a"
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"
6 changes: 6 additions & 0 deletions src/test/rustdoc-gui/sidebar-mobile.goml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/pa
click: "body"
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})

// Open the sidebar menu, and make sure pressing Escape closes it.
click: ".sidebar-menu-toggle"
assert-css: (".sidebar", {"left": "0px"})
press-key: "Escape"
assert-css: (".sidebar", {"display": "block", "left": "-1000px"})

// Check that the topbar is visible
assert-property: (".mobile-topbar", {"clientHeight": "45"})

Expand Down