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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:FluentTextArea enter key valid EditForm #1085

Open
be-swarm opened this issue Dec 7, 2023 · 5 comments
Open

fix:FluentTextArea enter key valid EditForm #1085

be-swarm opened this issue Dec 7, 2023 · 5 comments
Labels
area:fast A FAST-specific issue bug A bug status:blocked Any issue blocked by another

Comments

@be-swarm
Copy link

be-swarm commented Dec 7, 2023

🐛 Bug Report

When FluentTextArea is used in EditForm when enter key is pressed EditForm is submitted

💻 Code Sample

<EditForm Model="@_current" OnValidSubmit="@ActionNewMailTemplate">
    <BeSwarm.Validator.BlazorValidator ValidateContext="_validatorContext" />
    <FluentTextField Label="Code" @bind-Value=_current.TemplateName></FluentTextField>
    <ValidationMessage For="@(() => _current.TemplateName)" />
    <FluentSwitch @bind-Value=_current.IsBodyHtml>Html</FluentSwitch>
    <FluentTextField Label="Sujet" @bind-Value=_current.Subject></FluentTextField>
    <ValidationMessage For="@(() => _current.Subject)" />
    <FluentTextArea @bind-Value=_current.Body Placeholder="message ..."></FluentTextArea>
    <ValidationMessage For="@(() => _current.Body)" />
    <div>
        <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent "> Ajouter</FluentButton>
    </div>
</EditForm>
@code
{
   private async Task ActionNewMailTemplate()
   {
      ....
   }
}

ActionNewMailTemplate is called when enter key is pressed in FluentTextField

Is it possible to prevent this ?

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 7, 2023

Yes, remove the Type=ButtonType.Submit part from the FluentButton.

This is a workaround. We are looking for a bettter solution. I think this is related to #1050

@be-swarm
Copy link
Author

be-swarm commented Dec 7, 2023

In this case I no longer have editform validation.

@pingu2k4
Copy link

pingu2k4 commented Dec 7, 2023

Encountering this issue also - Removing the Submit button isn't great as we rely on that for its intended use. As in, we would lose other functionality we intend to keep.

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 8, 2023

See my additional comment in #1050. This is being caused by a bug in the underlying FAST script and can't be fixed until it is fixed there,

@yamanaiyuki
Copy link

Hello, I had a problem too.
My problem was with editing the bookmark details, not the email body.
I have prepared a way to enable validation for EditForm, without using Type=ButtonType.Submit as mentioned by vnbaaij.

  1. Switch from DataAnnotationsValidator to FluentValidationValidator.
  2. Use EditContext instead of Model (using both at the same time occurred an error.)
  3. Remove Type="ButtonType.Submit" and add OnClick="HandleSubmit".
  4. Finally, remove OnValidSubmit.

A working page and a example source are shown below.
https://wonderful-field-057679e00.5.azurestaticapps.net
https://github.com/yamanaiyuki/FluentTextArea1085/blob/main/Pages/WithoutSubmit.razor

In any case, this avoids the crisis of not being able to hit Enter in the TextArea.
Hopefully the underlying problem will be fixed soon.

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

No branches or pull requests

4 participants