Bug 1327560 - Always place the current lwtheme at the beginning of the list of recent lightweight themes to prevent it from getting truncated out. r=gijs
MozReview-Commit-ID: b3O3MnpmjG
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1389,19 +1389,26 @@ CustomizeMode.prototype = {
tbb.addEventListener("blur", resetPreview);
tbb.addEventListener("mouseout", resetPreview);
return tbb;
}
let themes = [aDefaultTheme];
let lwts = LightweightThemeManager.usedThemes;
+ let currentLwt = LightweightThemeManager.currentTheme;
+ let currentLwtIndex = lwts.indexOf(currentLwt);
+ if (currentLwtIndex > -1) {
+ // Make sure that the current lightweight theme
+ // is at the beginning of the array to avoid truncation
+ // in the next step.
+ lwts = lwts.splice(currentLwtIndex, 1).concat(lwts);
+ }
if (lwts.length > RECENT_LWT_COUNT)
lwts.length = RECENT_LWT_COUNT;
- let currentLwt = LightweightThemeManager.currentTheme;
for (let lwt of lwts) {
lwt.isActive = !!currentLwt && (lwt.id == currentLwt.id);
themes.push(lwt);
}
let footer = doc.getElementById("customization-lwtheme-menu-footer");
let panel = footer.parentNode;
let recommendedLabel = doc.getElementById("customization-lwtheme-menu-recommended");