Skip to content

Blazor SSR: enhanced form not working inside a dialog #65584

@sherman89

Description

@sherman89

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Enhanced form causes the dialog to close after submit, and UI becomes unresponsive:

<button onclick="emailModal.showModal()">Open modal</button>

<dialog id="emailModal" class="modal modal-bottom sm:modal-middle">
    <div class="modal-box">
        <button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2" 
                       type="button" onclick="emailModal.close()">
        ✕
        </button>

        <EditForm id="email-form" Model="Model" FormName="EmailForm" Enhance
                  OnValidSubmit="HandleValidEmailSubmit" OnInvalidSubmit="HandleInvalidEmailSubmit">
            <div>
                <label for="emailField" class="label">Email</label>
                <InputText @bind-Value="Model!.Email" @attributes="EmailFieldAttributes"
                           type="email" id="emailField" autocomplete="email"
                           title="Please enter a valid email" placeholder="Email"
                           required maxlength="@Constants.EmailMaxLength"
                           class="input validator w-full"/>
                <div class="mt-1 min-h-5">
                    <ValidationMessage For="@(() => Model!.Email)" class="text-error text-sm mt-1"/>
                </div>
            </div>

            <div class="modal-action">
                <button type="submit" id="submit-email-btn"
                        class="btn btn-primary">
                    Send!
                </button>
            </div>
        </EditForm>
    </div>
</dialog>

If I set data-permanent on a div wrapping the dialog, of course the issue goes away, but then my dialog becomes static...

I can handle submission in JavaScript and replace the HTML by hand, which works, but defeats the purpose of using enhanced navigation. Maybe I should switch to HTMX? I will if this is considered "by design" :)

Expected Behavior

Form HTML should be replaced without touching the dialog, since the form is inside the dialog and only the form and its children should be affected by enhanced loading.

Steps To Reproduce

  • Open dialog by clicking button
  • Submit form
  • Observe how dialog closes (shouldn't) and UI becomes unresponsive (as if invisible modal)

Exceptions (if any)

No response

.NET Version

10.0.103

Anything else?

ASP.NET Core version: 10.0.3
IDE: Visual Studio 2026 Community
Tailwind version: 4.1.17
daisyUI version: 5.5.8

dotnet --info output:

.NET SDK:
Version: 10.0.103
Commit: c2435c3e0f
Workload version: 10.0.100-manifests.c992be6d
MSBuild version: 18.0.11+c2435c3e0

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.103\

.NET workloads installed:
[maccatalyst]
Installation Source: VS 18.3.11520.95
Manifest Version: 26.2.10191/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.maccatalyst\26.2.10191\WorkloadManifest.json
Install Type: Msi

[ios]
Installation Source: VS 18.3.11520.95
Manifest Version: 26.2.10191/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.ios\26.2.10191\WorkloadManifest.json
Install Type: Msi

[android]
Installation Source: VS 18.3.11520.95
Manifest Version: 36.1.2/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.android\36.1.2\WorkloadManifest.json
Install Type: Msi

[wasm-tools]
Installation Source: VS 18.3.11520.95
Manifest Version: 10.0.103/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.workload.mono.toolchain.current\10.0.103\WorkloadManifest.json
Install Type: Msi

[maui-windows]
Installation Source: VS 18.3.11520.95
Manifest Version: 10.0.20/10.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\10.0.100\microsoft.net.sdk.maui\10.0.20\WorkloadManifest.json
Install Type: Msi

Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.3
Architecture: x64
Commit: c2435c3e0f

.NET SDKs installed:
10.0.103 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
DOTNET_CLI_TELEMETRY_OPTOUT [true]

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions