Skip to content

Commit 8344481

Browse files
committed
rustdoc: make help button a no-op when on help page
1 parent 65f501e commit 8344481

File tree

1 file changed

+15
-0
lines changed
  • src/librustdoc/html/static/js

1 file changed

+15
-0
lines changed

Diff for: src/librustdoc/html/static/js/main.js

+15
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,23 @@ function loadCss(cssFileName) {
951951

952952
if (isHelpPage) {
953953
showHelp();
954+
document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
955+
// Already on the help page, make help button a no-op.
956+
const target = event.target;
957+
if (target.tagName !== "A" ||
958+
target.parentElement.id !== HELP_BUTTON_ID ||
959+
event.ctrlKey ||
960+
event.altKey ||
961+
event.metaKey) {
962+
return;
963+
}
964+
event.preventDefault();
965+
});
954966
} else {
955967
document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
968+
// By default, have help button open docs in a popover.
969+
// If user clicks with a moderator, though, use default browser behavior,
970+
// probably opening in a new window or tab.
956971
const target = event.target;
957972
if (target.tagName !== "A" ||
958973
target.parentElement.id !== HELP_BUTTON_ID ||

0 commit comments

Comments
 (0)