fix updating text
This commit is contained in:
@@ -471,13 +471,14 @@ function saveDebounceMs(row: Const): number {
|
|||||||
|
|
||||||
function onValueChange(row: Const, value: string) {
|
function onValueChange(row: Const, value: string) {
|
||||||
if (row.id == null || isReadonly(row)) return
|
if (row.id == null || isReadonly(row)) return
|
||||||
|
|
||||||
drafts.value[row.id] = value
|
drafts.value[row.id] = value
|
||||||
if (resolveSettingFieldType(row) === 'longtext') {
|
|
||||||
return
|
// longtext هم باید ذخیره شود، فقط با delay بیشتر
|
||||||
}
|
|
||||||
scheduleSave(row)
|
scheduleSave(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function onFieldBlur(row: Const) {
|
function onFieldBlur(row: Const) {
|
||||||
if (row.id == null || isReadonly(row)) return
|
if (row.id == null || isReadonly(row)) return
|
||||||
scheduleSave(row, { flush: true })
|
scheduleSave(row, { flush: true })
|
||||||
@@ -486,18 +487,26 @@ function onFieldBlur(row: Const) {
|
|||||||
function scheduleSave(row: Const, options?: { flush?: boolean }) {
|
function scheduleSave(row: Const, options?: { flush?: boolean }) {
|
||||||
const id = row.id!
|
const id = row.id!
|
||||||
const delay = saveDebounceMs(row)
|
const delay = saveDebounceMs(row)
|
||||||
|
|
||||||
if (!debouncedSave.has(id)) {
|
if (!debouncedSave.has(id)) {
|
||||||
debouncedSave.set(
|
debouncedSave.set(
|
||||||
id,
|
id,
|
||||||
debounce(() => persistRowValue(id), delay)
|
debounce(() => {
|
||||||
|
void persistRowValue(id)
|
||||||
|
}, delay)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveFn = debouncedSave.get(id)!
|
const saveFn = debouncedSave.get(id)!
|
||||||
|
|
||||||
if (options?.flush) {
|
if (options?.flush) {
|
||||||
saveFn.flush()
|
// مهم: برای blur مستقیم ذخیره کن، نه فقط flush
|
||||||
} else {
|
saveFn.cancel()
|
||||||
saveFn()
|
void persistRowValue(id)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveFn()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function persistRowValue(id: number) {
|
async function persistRowValue(id: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user