Skip to content

Commit

Permalink
Rollup merge of #129824 - GuillaumeGomez:code-example-buttons-mobile,…
Browse files Browse the repository at this point in the history
… 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
matthiaskrgr committed Aug 31, 2024
2 parents b8b2a65 + 670a78b commit 828f7c8
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 828f7c8

Please sign in to comment.