Rollup merge of #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.
This commit is contained in:
Mazdak Farrokhzad
2019-08-06 15:36:30 +02:00
committed by GitHub

View File

@@ -877,16 +877,24 @@ fn write_shared(
r#"var themes = document.getElementById("theme-choices");
var themePicker = document.getElementById("theme-picker");
function switchThemeButtonState() {{
if (themes.style.display === "block") {{
function showThemeButtonState() {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}} else {{
}}
function hideThemeButtonState() {{
themes.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
}}
function switchThemeButtonState() {{
if (themes.style.display === "block") {{
showThemeButtonState();
}} else {{
hideThemeButtonState();
}}
}};
function handleThemeButtonsBlur(e) {{
@@ -898,7 +906,7 @@ function handleThemeButtonsBlur(e) {{
(!related ||
(related.id !== "themePicker" &&
(!related.parentNode || related.parentNode.id !== "theme-choices")))) {{
switchThemeButtonState();
hideThemeButtonState();
}}
}}