diff options
| author | Michael Howell <michael@notriddle.com> | 2022-11-08 17:59:03 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-11-11 18:27:42 -0700 |
| commit | 155750dc330d0a2148cff7efadd75d821854e947 (patch) | |
| tree | d716125b27226e9865648c2575cbd25380fdc7b8 | |
| parent | 89ba71649f59e402a0019828223a878c06f625b1 (diff) | |
| download | rust-155750dc330d0a2148cff7efadd75d821854e947.tar.gz rust-155750dc330d0a2148cff7efadd75d821854e947.zip | |
rustdoc: make notable traits popover behavior consistent with Help and Settings
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 10 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/notable-trait.goml | 28 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index b670ea3f020..0538762e44d 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -897,7 +897,15 @@ function loadCss(cssUrl) { !elemIsInParent(document.activeElement, window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE) && !elemIsInParent(event.relatedTarget, window.CURRENT_NOTABLE_ELEMENT.NOTABLE_BASE) ) { - hideNotable(); + // Work around a difference in the focus behaviour between Firefox, Chrome, and Safari. + // When I click the button on an already-opened notable trait popover, Safari + // hides the popover and then immediately shows it again, while everyone else hides it + // and it stays hidden. + // + // To work around this, make sure the click finishes being dispatched before + // hiding the popover. Since `hideNotable()` is idempotent, this makes Safari behave + // consistently with the other two. + setTimeout(hideNotable, 0); } } diff --git a/src/test/rustdoc-gui/notable-trait.goml b/src/test/rustdoc-gui/notable-trait.goml index 3bc1c5365e9..0b97cbae499 100644 --- a/src/test/rustdoc-gui/notable-trait.goml +++ b/src/test/rustdoc-gui/notable-trait.goml @@ -199,3 +199,31 @@ call-function: ( "trait_color": "rgb(110, 79, 201)", }, ) + +reload: + +// Check that pressing escape works +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" +move-cursor-to: "//*[@class='notable popover']" +assert-count: ("//*[@class='notable popover']", 1) +press-key: "Escape" +assert-count: ("//*[@class='notable popover']", 0) + +// 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) + +// Check that pressing tab over and over works. +click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']" +move-cursor-to: "//*[@class='notable popover']" +assert-count: ("//*[@class='notable popover']", 1) +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +press-key: "Tab" +assert-count: ("//*[@class='notable popover']", 0) |
