Bug 1463708 - only reset previews when leaving the panel, r?johannh
MozReview-Commit-ID: 1KVseuWlEPU
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1373,17 +1373,16 @@ CustomizeMode.prototype = {
tbb.setAttribute("aria-checked", isActive);
tbb.setAttribute("role", "menuitemradio");
if (isActive) {
tbb.setAttribute("active", "true");
}
tbb.addEventListener("focus", previewTheme);
tbb.addEventListener("mouseover", previewTheme);
tbb.addEventListener("blur", resetPreview);
- tbb.addEventListener("mouseout", resetPreview);
return tbb;
}
let themes = [];
let lwts = LightweightThemeManager.usedThemes;
let currentLwt = LightweightThemeManager.currentTheme;
@@ -1414,16 +1413,33 @@ CustomizeMode.prototype = {
button.theme.userDisabled = false;
else
LightweightThemeManager.currentTheme = button.theme;
onThemeSelected(panel);
});
panel.insertBefore(button, recommendedLabel);
}
+ function panelMouseOut(e) {
+ // mouseout events bubble, so we get mouseout events for the buttons
+ // in the panel. Here, we only care when the mouse actually leaves
+ // the panel. For some reason event.target might not be the panel
+ // even when the mouse *is* leaving the panel, so we check
+ // explicitOriginalTarget instead.
+ if (e.explicitOriginalTarget == panel) {
+ resetPreview();
+ }
+ }
+
+ panel.addEventListener("mouseout", panelMouseOut);
+ panel.addEventListener("popuphidden", () => {
+ panel.removeEventListener("mouseout", panelMouseOut);
+ resetPreview();
+ }, {once: true});
+
let lwthemePrefs = Services.prefs.getBranch("lightweightThemes.");
let recommendedThemes = lwthemePrefs.getStringPref("recommendedThemes");
recommendedThemes = JSON.parse(recommendedThemes);
let sb = Services.strings.createBundle("chrome://browser/locale/lightweightThemes.properties");
for (let theme of recommendedThemes) {
try {
theme.name = sb.GetStringFromName("lightweightThemes." + theme.id + ".name");
theme.description = sb.GetStringFromName("lightweightThemes." + theme.id + ".description");