fix updating text

This commit is contained in:
2026-06-21 13:27:16 +03:30
parent 555449791d
commit 01d0b82b61
+16 -7
View File
@@ -471,13 +471,14 @@ function saveDebounceMs(row: Const): number {
function onValueChange(row: Const, value: string) {
if (row.id == null || isReadonly(row)) return
drafts.value[row.id] = value
if (resolveSettingFieldType(row) === 'longtext') {
return
}
// longtext هم باید ذخیره شود، فقط با delay بیشتر
scheduleSave(row)
}
function onFieldBlur(row: Const) {
if (row.id == null || isReadonly(row)) return
scheduleSave(row, { flush: true })
@@ -486,18 +487,26 @@ function onFieldBlur(row: Const) {
function scheduleSave(row: Const, options?: { flush?: boolean }) {
const id = row.id!
const delay = saveDebounceMs(row)
if (!debouncedSave.has(id)) {
debouncedSave.set(
id,
debounce(() => persistRowValue(id), delay)
debounce(() => {
void persistRowValue(id)
}, delay)
)
}
const saveFn = debouncedSave.get(id)!
if (options?.flush) {
saveFn.flush()
} else {
saveFn()
// مهم: برای blur مستقیم ذخیره کن، نه فقط flush
saveFn.cancel()
void persistRowValue(id)
return
}
saveFn()
}
async function persistRowValue(id: number) {