diff --git a/src/pages/menuPages/configuration/index.vue b/src/pages/menuPages/configuration/index.vue index d957288..f5598f5 100644 --- a/src/pages/menuPages/configuration/index.vue +++ b/src/pages/menuPages/configuration/index.vue @@ -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) {