Closed vt512 closed 1 month ago
I can reproduce this behavior with the web component if the element is not attached to the DOM when dangerouslySetHtmlValue
is called:
<vaadin-rich-text-editor></vaadin-rich-text-editor>
<script type="module">
import '@vaadin/rich-text-editor';
const rte = document.querySelector('vaadin-rich-text-editor');
const htmlText = "Start<ul><li>P1</li><li>P2</li></ul>End";
rte.remove();
rte.dangerouslySetHtmlValue(htmlText);
document.body.append(rte);
</script>
When debugging this in combination with Dialog
, I can see that the element is already added to vaadin-dialog
at that point, so there must be something else that causes the same issue.
Seems to be a regression from https://github.com/vaadin/flow-components/pull/4538
The given patch from #6638 fixes the issue, when the RichTextEditor is placed inside a Dialog. But it is still not fixed, when it is placed inside a com.github.appreciated.layout.GridLayout (org.vaadin.addons.componentfactory:vaadin-css-grid-layout:3.0.0).
@vt512 Please create a new issue with a reproduction.
Description
Short description: Setting HTML text via
asHtml().setValue()
to a RichTextEditor which is displayed in a Dialog doesn't display the HTML text correctly in Firefox.Longer description: I'm adding a RichTextEditor inside a Dialog and set an HTML value via
asHtml().setValue(html)
. The text is displayed in the editor, but styling is corrupt (e.g. bullet list is missing) and newlines are lost. When placing the RichTextEditor directly on the view everything is fine.The same error occurs, when placing the RichTextEditor inside a com.github.appreciated.layout.GridLayout (org.vaadin.addons.componentfactory:vaadin-css-grid-layout:3.0.0).
The error occurs only in Firefox. In Chromium the HTML text is displayed correctly.
I debugged the setValue() call in Firefox. In RichTextEditorMixin the dangerouslySetHtmlValue(htmlValue) is called with the correct htmlValue. Inside that function the htmlValue is converted via
this._editor.clipboard.convert(htmlValue)
. The resultingdeltaFromHtml
doesn't contain the newline characters which exist in the working case.Expected outcome
The RichTextEditor should display the HTML text inside a Dialog correctly in the same way as it does on a View directly.
Minimal reproducible example
Steps to reproduce
Execute the minimal example above.
Environment
Vaadin version(s): 24.4.11, (in Vaadin 23 the HTML text is displayed correctly also inside a Dialog) OS: Linux
Browsers
Firefox