From 1969a59335b2edb28566dc06c69fb9a3e7a0908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Frimmel=20Mostr=C3=B6m?= Date: Tue, 11 Feb 2025 11:08:16 +0100 Subject: [PATCH] INT-3226: buffer editor change updates and make them async to prevent react issues. --- src/main/ts/components/Editor.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/ts/components/Editor.tsx b/src/main/ts/components/Editor.tsx index b9d3876d..cbae534b 100644 --- a/src/main/ts/components/Editor.tsx +++ b/src/main/ts/components/Editor.tsx @@ -146,6 +146,7 @@ export class Editor extends React.Component { private id: string; private elementRef: React.RefObject; + private latestUpdate: string | null = null; private inline: boolean; private currentContent?: string; private boundHandlers: Record) => unknown>; @@ -403,7 +404,15 @@ export class Editor extends React.Component { if (newContent !== this.currentContent) { this.currentContent = newContent; if (isFunction(this.props.onEditorChange)) { - this.props.onEditorChange(newContent, editor); + if (this.latestUpdate === null) { + setTimeout(() => { + if (this.props.onEditorChange && this.latestUpdate !== null) { + this.props.onEditorChange(this.latestUpdate, editor); + this.latestUpdate = null; + } + }); + } + this.latestUpdate = newContent; } } }