Skip to content

Commit ab2a368

Browse files
authored
Rollup merge of rust-lang#62837 - Kinrany:patch-1, r=GuillaumeGomez
Fix theme picker blur handler: always hide instead of switching Fixes a minor bug in UI generated by rustdoc. For example, this page: https://doc.rust-lang.org/std/ Reproduction steps: 1. Click the theme picker twice * The list of themes will be shown and then hidden 2. Click anywhere else * The list of themes will be show again, which is unexpected The bug was caused by blur event handler toggling the state of the element instead of always hiding it regardless of the current state.
2 parents f45cdea + 3e39ac7 commit ab2a368

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/librustdoc/html/render.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -877,15 +877,23 @@ fn write_shared(
877877
r#"var themes = document.getElementById("theme-choices");
878878
var themePicker = document.getElementById("theme-picker");
879879
880+
function showThemeButtonState() {{
881+
themes.style.display = "none";
882+
themePicker.style.borderBottomRightRadius = "3px";
883+
themePicker.style.borderBottomLeftRadius = "3px";
884+
}}
885+
886+
function hideThemeButtonState() {{
887+
themes.style.display = "block";
888+
themePicker.style.borderBottomRightRadius = "0";
889+
themePicker.style.borderBottomLeftRadius = "0";
890+
}}
891+
880892
function switchThemeButtonState() {{
881893
if (themes.style.display === "block") {{
882-
themes.style.display = "none";
883-
themePicker.style.borderBottomRightRadius = "3px";
884-
themePicker.style.borderBottomLeftRadius = "3px";
894+
showThemeButtonState();
885895
}} else {{
886-
themes.style.display = "block";
887-
themePicker.style.borderBottomRightRadius = "0";
888-
themePicker.style.borderBottomLeftRadius = "0";
896+
hideThemeButtonState();
889897
}}
890898
}};
891899
@@ -898,7 +906,7 @@ function handleThemeButtonsBlur(e) {{
898906
(!related ||
899907
(related.id !== "themePicker" &&
900908
(!related.parentNode || related.parentNode.id !== "theme-choices")))) {{
901-
switchThemeButtonState();
909+
hideThemeButtonState();
902910
}}
903911
}}
904912

0 commit comments

Comments
 (0)