From 84621484dabd5f60f0ce7990337745bcdbd0d915 Mon Sep 17 00:00:00 2001 From: cottongin Date: Wed, 26 Aug 2026 17:20:37 -0400 Subject: [PATCH] fix: reposition popover after picker opens, debounce popup saves - Popover: call positionPopover() after opening the picker so the popover flips above the badge if it would clip the viewport bottom. - Popup: debounce saveFromControls() calls during picker drag (200ms) to avoid dozens of storage writes per gesture. Co-authored-by: Cursor --- content/tweaks/color-popover.js | 1 + popup/popup.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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(); }); }