-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inhibit clicks on summary's children #91103
Conversation
Some changes occurred in HTML/CSS/JS. |
A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior. That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise. This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target.
bd1b456
to
9aef9a2
Compare
This comment has been minimized.
This comment has been minimized.
Please add a GUI test, otherwise it seems like a good idea. It often happens that when I highlight something, it closes the the doc, which is a bit annoying. |
goto: file://|DOC_PATH|/test_docs/struct.Foo.html | ||
size: (1000, 1000) | ||
assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) | ||
click: (249, 509) // This is the position of "pub" in "pub fn a_method" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can click directly on h4.code-header
. I'd much prefer avoiding to use hard coded positions if possible. :)
assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) | ||
click: (249, 509) // This is the position of "pub" in "pub fn a_method" | ||
assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""}) | ||
click: (229, 509) // This is the position of "[-]" next to that pub fn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -0,0 +1,10 @@ | |||
// This test ensures that clicking on a method summary, but not on the "[-]", | |||
// doesn't toggle the <details>. | |||
debug: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you're done, please remove this one. ;)
I wrote a GUI test, but I couldn't get it to work. I tried to find the coordinates on which to simulate a click by loading the page in a regular browser, but when I tell the tester to click on the coordinates that correspond to the toggle, it doesn't appear to do anything. I tried using |
Ah right, for that I use |
fa0e2c3
to
3f3a7a2
Compare
Looks good to me, one nit remaining but can be ignored. |
3f3a7a2
to
7f35556
Compare
Thanks! r=me once CI pass |
@bors try |
⌛ Trying commit 7f35556 with merge 057c2213acefad12356c4f990ecff30c5b32bdf6... |
Why the try? |
Perhaps I misread the bors docs? Was attempting to trigger a normal re-run of the tests, since I can't reproduce the failure locally. And the CI status reported here doesn't show a failure, just a cancelled check? https://bors.tech/documentation/ |
It's easier this way. ;) |
@bors r=Manishearth,GuillaumeGomez |
📌 Commit 7f35556 has been approved by |
…, r=Manishearth,GuillaumeGomez Inhibit clicks on summary's children A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior. That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise. This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target. r? `@Manishearth`
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#90856 (Suggestion to wrap inner types using 'allocator_api' in tuple) - rust-lang#91103 (Inhibit clicks on summary's children) - rust-lang#91137 (Give people a single link they can click in the contributing guide) - rust-lang#91140 (Split inline const to two feature gates and mark expression position inline const complete) - rust-lang#91148 (Use `derive_default_enum` in the compiler) - rust-lang#91153 (kernel_copy: avoid panic on unexpected OS error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…eGomez Fix toggle-click-deadspace rustdoc-gui test In rust-lang#91103 I introduced a rustdoc-gui test for clicks on toggles. I introduced some documentation on a method in lib2/struct.Foo.html so there would be something to toggle, but accidentally left the test checking test_docs/struct.Foo.html. That caused the test to reliably fail. I'm not sure how that test got past GitHub Actions and bors, but it's manifesting in test failures at rust-lang#91062 (comment) and rust-lang#91170 (comment). This fixes by pointing at the right file. r? `@GuillaumeGomez`
A byproduct of using
<details>
and<summary>
to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior.That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise.
This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a
<div>
, which is the target for anything that doesn't have a more specific target.r? @Manishearth