RichTextEditor.AsDelta.setValue() - silently restore old content

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;
    });

Thanks for the feedback. A new issue in Issues ยท vaadin/flow-components ยท GitHub would be a suitable place to file issues.

It would also be appreciated if the summary was an actual summary in the form of a short paragraph or bullet list that describes what the problem is. LLMs tend to produce descriptions that are rather hard to parse, so using them as-is rarely results in a good bug ticket.

1 Like