@@ -789,7 +789,8 @@ fn write_shared(cx: &Context,
789
789
format ! (
790
790
r#"var themes = document.getElementById("theme-choices");
791
791
var themePicker = document.getElementById("theme-picker");
792
- themePicker.onclick = function() {{
792
+
793
+ function switchThemeButtonState() {{
793
794
if (themes.style.display === "block") {{
794
795
themes.style.display = "none";
795
796
themePicker.style.borderBottomRightRadius = "3px";
@@ -800,12 +801,29 @@ themePicker.onclick = function() {{
800
801
themePicker.style.borderBottomLeftRadius = "0";
801
802
}}
802
803
}};
804
+
805
+ function handleThemeButtonsBlur(e) {{
806
+ var active = document.activeElement;
807
+ var related = e.relatedTarget;
808
+
809
+ if (active.id !== "themePicker" &&
810
+ (!active.parentNode || active.parentNode.id !== "theme-choices") &&
811
+ (!related ||
812
+ (related.id !== "themePicker" &&
813
+ (!related.parentNode || related.parentNode.id !== "theme-choices")))) {{
814
+ switchThemeButtonState();
815
+ }}
816
+ }}
817
+
818
+ themePicker.onclick = switchThemeButtonState;
819
+ themePicker.onblur = handleThemeButtonsBlur;
803
820
[{}].forEach(function(item) {{
804
821
var but = document.createElement('button');
805
822
but.innerHTML = item;
806
823
but.onclick = function(el) {{
807
824
switchTheme(currentTheme, mainTheme, item);
808
825
}};
826
+ but.onblur = handleThemeButtonsBlur;
809
827
themes.appendChild(but);
810
828
}});"# ,
811
829
themes. iter( )
0 commit comments