Skip to content

fix: double submit with Enter #1050

@iotalambda

Description

@iotalambda

🐛 Bug Report

When navigating to an EditForm's submit button by keyboard and hitting Enter, submit occurs twice.

💻 Repro or Code Sample

dotnet new install Microsoft.FluentUI.AspNetCore.Templates::4.1.1
dotnet new fluentblazor

Replace Counter.razor content with the following, tab your way to the FluentButton and hit Enter -> current count is incremented by 2.

@page "/counter"
@rendermode InteractiveServer

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: <FluentBadge Appearance="Appearance.Neutral">@currentCount</FluentBadge></p>

<EditForm OnValidSubmit=@IncrementCount Model="new { }">
    <button type="submit">Submit with normal button -> +1</button>
    <FluentButton Appearance="Appearance.Accent" Type=@ButtonType.Submit>Submit with FluentButton -> +2</FluentButton>
</EditForm>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }
}

🌍 Your Environment

Occurs at least in Edge and Firefox

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions