fix: only persist edited/existing mode overrides, refresh popover theme on dark mode toggle

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 16:11:24 -04:00
parent dd92ce8f0a
commit 210676e65b
3 changed files with 65 additions and 8 deletions

View File

@@ -103,9 +103,15 @@
light: { bg: bgInput.value, border: borderInput.value, text: textInput.value },
dark: { bg: colorToHex(darkColors.bg), border: colorToHex(darkColors.border), text: colorToHex(darkColors.text) },
};
entry._hadOverride = {
light: !!(modeColors && modeColors.light),
dark: !!(modeColors && modeColors.dark),
};
entry._dirtyModes = { light: false, dark: false };
modeSelect.addEventListener("change", function () {
var prev = modeSelect.value === "dark" ? "light" : "dark";
entry._dirtyModes[prev] = true;
entry._colorState[prev] = { bg: bgInput.value, border: borderInput.value, text: textInput.value };
var next = entry._colorState[modeSelect.value];
bgInput.value = next.bg;
@@ -114,7 +120,12 @@
});
[nameInput, bgInput, borderInput, textInput].forEach(function (input) {
input.addEventListener("change", saveFromControls);
input.addEventListener("change", function () {
if (input !== nameInput) {
entry._dirtyModes[modeSelect.value] = true;
}
saveFromControls();
});
});
entry.appendChild(header);
@@ -144,10 +155,17 @@
text: entry._textInput.value,
};
overrides[name] = {
light: entry._colorState.light,
dark: entry._colorState.dark,
};
var entryOverrides = {};
if (entry._hadOverride.light || entry._dirtyModes.light) {
entryOverrides.light = entry._colorState.light;
}
if (entry._hadOverride.dark || entry._dirtyModes.dark) {
entryOverrides.dark = entry._colorState.dark;
}
if (entryOverrides.light || entryOverrides.dark) {
overrides[name] = entryOverrides;
}
});
return overrides;
}