This repository was archived by the owner on Dec 26, 2025. It is now read-only.
-
- Notifications
You must be signed in to change notification settings - Fork 93
This repository was archived by the owner on Dec 26, 2025. It is now read-only.
The validation message does not appear correctly when the Enter key is used (FluentValidation & Blazored.FluentValidation). #249
Copy link
Copy link
Open
Labels
BugSomething isn't workingSomething isn't workingTriageIssue needs to be triagedIssue needs to be triaged
Description
Description
While testing FluentValidation and Blazored.FluentValidation with the InputText component's ValueChanged event, observed that the validation message works correctly when using the Tab key or clicking away from the field. However, when the Enter key is used, the validation message does not appear and only flashes briefly.
@using Blazored.FluentValidation @using FluentValidation <div style="margin: 150px auto; width: 50%"> <EditForm Model="@_annotation"> <FluentValidationValidator @ref="_testFluentValidationValidator" /> <InputText class="form-control" Value="@_annotation.Name" ValueChanged="ChangeValue" ValueExpression="@(() => _annotation.Name)"></InputText> <ValidationMessage For="@(() => _annotation.Name)" /> </EditForm> </div> @code { private FluentValidationValidator? _testFluentValidationValidator; private Annotation _annotation = new(); protected async Task ChangeValue(string newValue) { _annotation.Name = newValue; var result = (await _testFluentValidationValidator!.ValidateAsync(options => options.IncludeRuleSets("TestNames"))); if (result) { await Task.Delay(100); } else { await Task.Delay(100); } } public class AnnotationValidator : AbstractValidator<Annotation> { public AnnotationValidator() { RuleSet("TestNames", () => { RuleFor(e => e.Name) .NotEmpty().WithMessage("Please enter a name.") .MinimumLength(3).WithMessage($"Name must be longer than 2 characters."); }); } } public class Annotation { public string Name { get; set; } } } To Reproduce
Steps to reproduce the behavior:
- Run the code snippet provided above.
- Focus on the input field and type "A".
- Press the Enter key.
Expected behavior
The validation message needs to be displayed properly.
Video of the issue:
1436.mp4
Hosting Model (is this issue happening with a certain hosting model?):
- Blazor Server
- Blazor WebAssembly
Additional context
While testing the same scenario with Jeremy FluentValidation, it worked well.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingTriageIssue needs to be triagedIssue needs to be triaged