From e08cc42ee603103e97d3ff872d9d7f4cc9c26020 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Mon, 18 Nov 2024 15:07:50 +0800 Subject: [PATCH 1/2] fix: add isValidatingValue state to fix call validateValue api repeatedly #2830 --- packages/vtable/src/edit/edit-manager.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/vtable/src/edit/edit-manager.ts b/packages/vtable/src/edit/edit-manager.ts index a801db35b..7a73d4891 100644 --- a/packages/vtable/src/edit/edit-manager.ts +++ b/packages/vtable/src/edit/edit-manager.ts @@ -10,6 +10,7 @@ import { isValid } from '@visactor/vutils'; export class EditManeger { table: BaseTableAPI; editingEditor: IEditor; + isValidatingValue: boolean = false; editCell: { col: number; row: number }; constructor(table: BaseTableAPI) { @@ -121,7 +122,9 @@ export class EditManeger { if (!this.editingEditor) { return true; } - + if (this.isValidatingValue) { + return false; + } const target = e?.target as HTMLElement | undefined; const { editingEditor: editor } = this; @@ -141,6 +144,7 @@ export class EditManeger { console.warn('VTable Warn: `getValue` is not provided, did you forget to implement it?'); } if (this.editingEditor.validateValue) { + this.isValidatingValue = true; const maybePromiseOrValue = this.editingEditor.validateValue?.(); if (isPromise(maybePromiseOrValue)) { return new Promise((resolve, reject) => { @@ -150,10 +154,12 @@ export class EditManeger { this.doExit(); resolve(true); } else { + this.isValidatingValue = false; resolve(false); } }) .catch((err: Error) => { + this.isValidatingValue = false; console.error('VTable Error:', err); reject(err); }); @@ -184,6 +190,7 @@ export class EditManeger { this.editingEditor.exit?.(); this.editingEditor.onEnd?.(); this.editingEditor = null; + this.isValidatingValue = false; } cancelEdit() { From 2bcf317d39d20b246e8fc42115c12aed72260611 Mon Sep 17 00:00:00 2001 From: fangsmile <892739385@qq.com> Date: Mon, 18 Nov 2024 15:08:11 +0800 Subject: [PATCH 2/2] docs: update changlog of rush --- ...tor-validatevalue-repeatedly_2024-11-18-07-08.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vtable/2830-bug-editor-validatevalue-repeatedly_2024-11-18-07-08.json diff --git a/common/changes/@visactor/vtable/2830-bug-editor-validatevalue-repeatedly_2024-11-18-07-08.json b/common/changes/@visactor/vtable/2830-bug-editor-validatevalue-repeatedly_2024-11-18-07-08.json new file mode 100644 index 000000000..7ef676739 --- /dev/null +++ b/common/changes/@visactor/vtable/2830-bug-editor-validatevalue-repeatedly_2024-11-18-07-08.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: add isValidatingValue state to fix call validateValue api repeatedly #2830\n\n", + "type": "none", + "packageName": "@visactor/vtable" + } + ], + "packageName": "@visactor/vtable", + "email": "892739385@qq.com" +} \ No newline at end of file