RichTextEditor.AsDelta.setValue() stale-echo race condition silently restores old content
Component
com.vaadin.flow.component.richtexteditor.RichTextEditor (AsDelta.setValue)
Versions
- Vaadin: 24.x โ 25.2.2
- Java: 25
Summary
- Problem:
RichTextEditor.AsDelta.setValue()schedules an async JS call (executeJs("return this.htmlValue")) to sync HTML presentation back to the server. - Race Condition: When reusing an editor instance across entities (e.g. Master/Detail view), calling
setValue()rapidly causes earlier pending HTML promises to resolve late with stale content. - Impact: Resolving late calls
setValue(staleHtml)โdangerouslySetHtmlValue(), silently overwriting the current/new content with stale data.
Code Location
// AsDelta#setValue
RichTextEditor.this.getElement()
.executeJs("return this.htmlValue").then(jsonNode -> {
isHtmlValueSync = true;
RichTextEditor.this.setValue(jsonNode.asString()); // Late stale execution
isHtmlValueSync = false;
});