umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Umbraco Forms Block in RTE causes infinite loop (V14) #1268

Closed arcjawsh closed 2 months ago

arcjawsh commented 2 months ago

In Umbraco 14, rendering an umbraco form in a richtext editor via a block causes an infinite render loop. Occurs with both Component.InvokeAsync and asp core tag helper. Using in Block Grid or Block List works fine.

Reproduction

Create new Umbraco 14 Starter project Add Umbraco.Forms 14.1 Add Document type with richtext property / create test page that renders richtext property Add Richtext component view for block (/Views/Partials/RichText/Components/UmbracoForm.cshtml) with code:

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.RichTextBlockItem>
@{
    var theme = Model.Content.Value<string>("theme");
    var formId = Model.Content.Value<string>("form");

    // NOTE: The page will require <partial name="_ValidationScriptsPartial" /> to be included.
}

@(await Component.InvokeAsync("RenderForm",new { formId = Guid.Parse(formId), theme = theme, includeScripts = true}))

Add a new element with the following configuration (export doctype seems to be missing in u14): element

Add block to richtext editor available blocks Make test umbraco form Add form block to richtext editor for test page Put breakpoints in block view and watch it infinitely hit

Specifics

Umbraco.Cms 14.1.1 Umbraco.Forms 14.1.0 Chrome/Brave/Edge

Notes / Quirks

Even when the richtext is not rendered (but contains the umbraco form block) and the umbraco form render component is invoked - it will still hit the breakpoints in the RTE component file. Remove the block from the RTE and everything is fine. eg.

@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
    Layout = "Layout.cshtml";
    var html = Model.Value<string>("html");
}

<div class="container py-5">
    @* @await Html.GetBlockGridHtmlAsync(Model, "content") *@
    @* @(Model.Value("richtextContent")) *@
    @await Component.InvokeAsync("RenderForm", new { formId = Guid.Parse("e7ba6c1c-8964-47a6-bb78-925dae11afc1"), theme = "default", includeScripts = true}) 
</div>

The loop still happens and breakpoint hits in partial file (/Views/Partials/RichText/Components/UmbracoForm.cshtml), even though there is NO reference to the component.

Please let me know if I can provide any more information or code to reproduce.


This item has been added to our backlog AB#42691

AndyButland commented 2 months ago

Thanks for the report and clear replication steps @arcjawsh. We have found and resolved the issue, which will be in the next patch release.

This is actually a situation we had handled before - rendering forms in the rich text editor - but had some logic behind a check for the rich text editor alias, which has changed in Umbraco 14. Having updated this to the new alias, I no longer see the issue.