1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-20 06:21:09 +02:00

Fix: Click anywhere on the language switch menu to switch the language (#2144)

close: https://github.com/google/comprehensive-rust/issues/2132
This commit is contained in:
Rush 2024-06-14 00:17:26 +08:00 committed by GitHub
parent e70de3eb27
commit d2f8fc4ac5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -224,6 +224,18 @@
lang.href = `${full_path_to_root}${lang.id}/${path}`;
}
}
// When the user clicks a list item, the page jump is performed, just like clicking the internal <a> tag.
langList.querySelectorAll("li").forEach(function(li) {
li.addEventListener("click", function(event) {
event.preventDefault();
let link = this.querySelector("a");
if (link && window.location.href !== link.href) {
window.location.href = link.href;
}
});
});
</script>
{{#if print_enable}}