Markdown RichTextEditor in Modal SfDialog renders incorrectly.
When using an SfRichTextEditor in Markdown Editor Mode inside of a SfDialog where IsModal is 'true', the height of the RTE does not render properly. I make calls to rteObj.RefreshUIAsync() in both the Created callback for the RTE and the Opened callback of the dialog, to no avail. When in Markup mode, the issue is not present.
The issue is reproduced in the following Syncfusion playground.
Please provide any insight as to how I can resolve this issue.
Thank you.
Hi Hunter Malley,
Thank you for reaching out.
We have reviewed your query and found that the issue does not occur in our local environment but is reproducible in the online playground sample. This may be due to the editor's height being calculated before the dialog opens.
To resolve this, we recommend explicitly setting the Height property of the SfRichTextEditor.
Screenshot Reference:
Sample Link: https://blazorplayground.syncfusion.com/rjhoNqDQJIPNxLcy
Could you please try this solution and let us know if the issue persists?
Looking forward to your response.
Thanks,
Bhuvaneshwari T
Thank you for your response.
I am looking to use the component to display content of varying heights and therefore do not want to set the height as a literal. Is there no way to have the height be calculated dynamically and be responsive? I assumed the calls to RefreshUIAsync() in the RTE Created() and Dialogue Opened() callbacks would recalculate the height.
Best,
Hunter
Hi Hunter Malley,
As mentioned earlier, the issue does not occur in our local environment but is reproducible only in the online playground sample.
For your reference, we have attached the sample and a screenshot.
Could you please check this in your local environment and let us know if the issue is replicated locally?
Thanks,
Bhuvaneshwari T
Attachment: BlazorRTE_f7218a07.zip
Good morning,
Thank you for including that sample. In the sample, it looks like a using statement for Syncfusion.Blazor.Popups is not included in the _Imports.razor. After adding that line so the content is actually presented in a Dialogue component, the issue is replicated for me locally.
Is the issue replicated locally, on your end, when the Dialogue component is properly set up?
Best,
Hunter
Hello,
I am just following up on this issue.
Best,
Hunter
await JS.InvokeVoidAsync("adjustTextareaHeight", "benefits_editable-content"); |
window.adjustTextareaHeight = (textareaId) => { let textarea = document.getElementById(textareaId); if (textarea) { textarea.style.height = "auto"; // Reset height to recalculate textarea.style.height = textarea.scrollHeight + "px"; // Set new height } }; |
Screenshot reference:
Attachment: BlazorRTE_a8496435.zip
Thank you very much for providing that work around.
While that solution works, appropriately resizing the RTE on dialog open, it causes the form to be a bit jumpy when opened. The element first has the default height, and then jumps down to the correct, calculated height.
Are there any plans to address this issue with the SfRichTextEditor in Markdown mode in a future patch?
Best,
Hunter
Now you can track the status of the reported issue through this feedback,
Root cause: For markdown editor, we are setting the height manually by calculating the scroll height but when it rendered inside the dialog rte is not in the dom, height calculation will be zero
Thank you for reaching out.
In Markdown mode, the Rich Text Editor is rendered as a <textarea>, and its height is not automatically calculated. The height is determined based on the scroll height, which becomes available only after the element is appended to the DOM.
When the editor is placed inside a dialog, it is usually rendered before the dialog opens. Since the editor is not yet appended to the DOM at that point, its scroll height is zero. This causes the jumpy behavior you observed, where the editor resizes after the dialog is displayed.
To resolve this, we recommend initializing the Rich Text Editor only after the dialog has fully opened. This ensures that the editor calculates its height correctly and avoids visual flicker. In the example below, the editor is conditionally rendered based on a flag set in the DialogOpenedHandler:
<SfDialog ShowCloseIcon="true" AllowPrerender="true" IsModal="true" CssClass="wtbi-modal" ZIndex="200000"> <DialogEvents OnOpen="@DialogOpenedHandler"></DialogEvents> <DialogTemplates> <Header>Details</Header> <Content> <div id="details-target" class="h-100"> @if (isDropDownOpen) { <SfRichTextEditor id="benefits" @ref="@BenefitsRteComponent" @bind-Value="@Benefit" EditorMode="EditorMode.Markdown"> <RichTextEditorEvents Created="@OnBenefitsRteCreated"></RichTextEditorEvents> <RichTextEditorToolbarSettings></RichTextEditorToolbarSettings> </SfRichTextEditor> } </div> </Content> </DialogTemplates> </SfDialog> @code { public bool isDropDownOpen { get; set; } = false; public SfRichTextEditor BenefitsRteComponent { get; set; } public async Task DialogOpenedHandler() { isDropDownOpen = true; } } |
We've also attached a sample and screen recording for your reference.
We appreciate your feedback and will consider this behavior for improvement in a future update.
Best regards,
Bhuvaneshwari T
Attachment: BlazorRTE_4ad407fc.zip
html, body { height: 100%; }
Bhuvaneshwari T
- 11 Replies
- 2 Participants
-
HM Hunter Malley
- Mar 6, 2025 03:09 PM UTC
- Jun 19, 2025 05:14 AM UTC