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:
@@ -161,6 +161,7 @@
|
|||||||
row.hex.classList.remove("rt-input-error");
|
row.hex.classList.remove("rt-input-error");
|
||||||
updatePreview();
|
updatePreview();
|
||||||
});
|
});
|
||||||
|
if (currentAnchor) positionPopover(currentAnchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closePicker() {
|
function closePicker() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
var picker = null;
|
var picker = null;
|
||||||
var activeSwatchEl = null;
|
var activeSwatchEl = null;
|
||||||
|
var saveDebounceTimer = null;
|
||||||
|
|
||||||
var COLOR_KEYS = [
|
var COLOR_KEYS = [
|
||||||
"light.subredditBgColor",
|
"light.subredditBgColor",
|
||||||
@@ -33,6 +34,11 @@
|
|||||||
el.style.backgroundColor = val;
|
el.style.backgroundColor = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function debouncedSave() {
|
||||||
|
clearTimeout(saveDebounceTimer);
|
||||||
|
saveDebounceTimer = setTimeout(saveFromControls, 200);
|
||||||
|
}
|
||||||
|
|
||||||
function openPickerForSwatch(swatchEl, onBeforeChange) {
|
function openPickerForSwatch(swatchEl, onBeforeChange) {
|
||||||
if (!picker) {
|
if (!picker) {
|
||||||
picker = window.RedditTweaks.colorPicker.create();
|
picker = window.RedditTweaks.colorPicker.create();
|
||||||
@@ -51,7 +57,7 @@
|
|||||||
picker.open(getColorValue(swatchEl), function (hex) {
|
picker.open(getColorValue(swatchEl), function (hex) {
|
||||||
setColorValue(swatchEl, hex);
|
setColorValue(swatchEl, hex);
|
||||||
if (onBeforeChange) onBeforeChange();
|
if (onBeforeChange) onBeforeChange();
|
||||||
saveFromControls();
|
debouncedSave();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user