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 <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 17:20:37 -04:00
parent 1b4b5706de
commit 84621484da
2 changed files with 8 additions and 1 deletions

View File

@@ -161,6 +161,7 @@
row.hex.classList.remove("rt-input-error");
updatePreview();
});
if (currentAnchor) positionPopover(currentAnchor);
}
function closePicker() {

View File

@@ -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();
});
}