Skip to content

Commit 670a78b

Browse files
Fix code examples buttons not appearing on click on mobile
1 parent 0d63418 commit 670a78b

File tree

1 file changed

+8
-2
lines changed
  • src/librustdoc/html/static/js

1 file changed

+8
-2
lines changed

src/librustdoc/html/static/js/main.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1878,9 +1878,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
18781878
if (elem === null) {
18791879
return;
18801880
}
1881-
const buttons = elem.querySelector(".button-holder");
1881+
let buttons = elem.querySelector(".button-holder");
18821882
if (buttons === null) {
1883-
return;
1883+
// On mobile, you can't hover an element so buttons need to be created on click
1884+
// if they're not already there.
1885+
addCopyButton(event);
1886+
buttons = elem.querySelector(".button-holder");
1887+
if (buttons === null) {
1888+
return;
1889+
}
18841890
}
18851891
buttons.classList.toggle("keep-visible");
18861892
}

0 commit comments

Comments
 (0)