Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: double submit with Enter #1050

Open
iotalambda opened this issue Dec 1, 2023 · 6 comments
Open

fix: double submit with Enter #1050

iotalambda opened this issue Dec 1, 2023 · 6 comments
Labels
area:fluent-ui-web-components A FluentUI specific issue bug A bug status:blocked Any issue blocked by another

Comments

@iotalambda
Copy link

馃悰 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

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 1, 2023

I just tried it with same template and your exact code. Not seeing this behavior:
counter-#1050

@iotalambda
Copy link
Author

I just tried it with same template and your exact code. Not seeing this behavior: counter-#1050 counter-#1050

Did you submit by clicking the button? The bug does not occur when submitting by clicking - only when submitting by activating the button and then hitting Enter on your keyboard.

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 1, 2023

No, did not do that. Will try that next

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 7, 2023

Ok, can reproduce with Enter keypress...weird.
While we search for a solution, a workaround is to remove the Type=ButtonType.Submit part from the code. The IncrementCount method will then only be called once.

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 8, 2023

Of course, removing the submit is not alway going to be a viable solution.

I've traced back the bug all the way to the FAST source code (which is what is used to build the fluent-button web component that we wrap in our FluentButton component): microsoft/fast#6704.

Unfortunately, it needs to be fixed there first. After that we need to get a new release of the web components script and integrate that in our library. I'm in contact with the FAST maintainers to see if and how this can be expidited but I'm afraid this behavior can not be changed/circumvented when usen the keyboard until the scripts get fixed.

@vnbaaij vnbaaij added bug A bug area:fast-blazor status:blocked Any issue blocked by another labels Dec 8, 2023
@iotalambda
Copy link
Author

Thanks @vnbaaij. Too bad the problem lies so deep.

Also, another workaround is to use a non-fluent submit button for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fluent-ui-web-components A FluentUI specific issue bug A bug status:blocked Any issue blocked by another
Projects
None yet
Development

No branches or pull requests

2 participants