Skip to content

Commit

Permalink
rustdoc: make help button a no-op when on help page
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 16, 2022
1 parent 65f501e commit 8344481
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,23 @@ function loadCss(cssFileName) {

if (isHelpPage) {
showHelp();
document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
// Already on the help page, make help button a no-op.
const target = event.target;
if (target.tagName !== "A" ||
target.parentElement.id !== HELP_BUTTON_ID ||
event.ctrlKey ||
event.altKey ||
event.metaKey) {
return;
}
event.preventDefault();
});
} else {
document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
// By default, have help button open docs in a popover.
// If user clicks with a moderator, though, use default browser behavior,
// probably opening in a new window or tab.
const target = event.target;
if (target.tagName !== "A" ||
target.parentElement.id !== HELP_BUTTON_ID ||
Expand Down

0 comments on commit 8344481

Please sign in to comment.