Skip to content

Commit

Permalink
Rollup merge of rust-lang#62837 - Kinrany:patch-1, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Centril authored Aug 6, 2019
2 parents e699471 + 3e39ac7 commit a389521
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,15 +877,23 @@ fn write_shared(
r#"var themes = document.getElementById("theme-choices");
var themePicker = document.getElementById("theme-picker");
function showThemeButtonState() {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}}
function hideThemeButtonState() {{
themes.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
}}
function switchThemeButtonState() {{
if (themes.style.display === "block") {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
showThemeButtonState();
}} else {{
themes.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
hideThemeButtonState();
}}
}};
Expand All @@ -898,7 +906,7 @@ function handleThemeButtonsBlur(e) {{
(!related ||
(related.id !== "themePicker" &&
(!related.parentNode || related.parentNode.id !== "theme-choices")))) {{
switchThemeButtonState();
hideThemeButtonState();
}}
}}
Expand Down

0 comments on commit a389521

Please sign in to comment.