Skip to content

Commit

Permalink
Unrolled build for rust-lang#129824
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#129824 - GuillaumeGomez:code-example-buttons-mobile, r=notriddle

Fix code examples buttons not appearing on click on mobile

When browsing docs on mobile today, I realized that the buttons didn't appear when I tapped on the code example.

One issue: I have no idea how to add a regression test for this case...

r? ``@notriddle``
  • Loading branch information
rust-timer authored Aug 31, 2024
2 parents d571ae8 + 670a78b commit 75ab755
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1878,9 +1878,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
if (elem === null) {
return;
}
const buttons = elem.querySelector(".button-holder");
let buttons = elem.querySelector(".button-holder");
if (buttons === null) {
return;
// On mobile, you can't hover an element so buttons need to be created on click
// if they're not already there.
addCopyButton(event);
buttons = elem.querySelector(".button-holder");
if (buttons === null) {
return;
}
}
buttons.classList.toggle("keep-visible");
}
Expand Down

0 comments on commit 75ab755

Please sign in to comment.