Skip to content

Commit

Permalink
Fix code examples buttons not appearing on click on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 31, 2024
1 parent 0d63418 commit 670a78b
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 670a78b

Please sign in to comment.