diff --git a/content/tweaks/color-popover.js b/content/tweaks/color-popover.js index f74094f..87837b6 100644 --- a/content/tweaks/color-popover.js +++ b/content/tweaks/color-popover.js @@ -161,6 +161,7 @@ row.hex.classList.remove("rt-input-error"); updatePreview(); }); + if (currentAnchor) positionPopover(currentAnchor); } function closePicker() { diff --git a/popup/popup.js b/popup/popup.js index 077cfd5..4b46269 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -3,6 +3,7 @@ var picker = null; var activeSwatchEl = null; + var saveDebounceTimer = null; var COLOR_KEYS = [ "light.subredditBgColor", @@ -33,6 +34,11 @@ el.style.backgroundColor = val; } + function debouncedSave() { + clearTimeout(saveDebounceTimer); + saveDebounceTimer = setTimeout(saveFromControls, 200); + } + function openPickerForSwatch(swatchEl, onBeforeChange) { if (!picker) { picker = window.RedditTweaks.colorPicker.create(); @@ -51,7 +57,7 @@ picker.open(getColorValue(swatchEl), function (hex) { setColorValue(swatchEl, hex); if (onBeforeChange) onBeforeChange(); - saveFromControls(); + debouncedSave(); }); }