From 2c5dd71c72e837847237c53ae460d9caa886f3e3 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 8 Jan 2024 09:27:52 -0700 Subject: [PATCH] rustdoc: hide modals when resizing the sidebar Follow-up for https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011 --- src/librustdoc/html/static/js/main.js | 1 + .../sidebar-resize-close-popover.goml | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/rustdoc-gui/sidebar-resize-close-popover.goml diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 88901191cda25..b17e7ede2ac49 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1721,6 +1721,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm } currentPointerId = e.pointerId; } + hideAllModals(false); e.preventDefault(); window.addEventListener("pointermove", resize, false); window.addEventListener("pointercancel", stopResize, false); diff --git a/tests/rustdoc-gui/sidebar-resize-close-popover.goml b/tests/rustdoc-gui/sidebar-resize-close-popover.goml new file mode 100644 index 0000000000000..2a8fbac855e97 --- /dev/null +++ b/tests/rustdoc-gui/sidebar-resize-close-popover.goml @@ -0,0 +1,20 @@ +// Checks sidebar resizing close the Settings popover +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +assert-property: (".sidebar", {"clientWidth": "200"}) +show-text: true +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +// normal resizing +drag-and-drop: ((205, 100), (185, 100)) +assert-property: (".sidebar", {"clientWidth": "182"}) +assert-css: ("#settings", {"display": "none"}) + +// Now same thing, but for source code +go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" +click: "#settings-menu" +wait-for: "#settings" +assert-css: ("#settings", {"display": "block"}) +assert-property: (".sidebar", {"clientWidth": "49"}) +drag-and-drop: ((52, 100), (185, 100)) +assert-css: ("#settings", {"display": "none"})