Skip to content

DataAnnotationsValidator never de-registering events (AddDataAnnotationsValidation) #31027

Closed
@YannikBartel

Description

@YannikBartel

Multiple ValidationMessages are generated for the same single validation.

DataAnnotationsValidator registering events by EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation. If the DataAnnotationsValidator gets re-rendered, its registering same events again. It can be same EditContext though. Because its never deregistering, its registering multiple times, results in multiple ValidationMessages for the same validation.

(namespace is Microsoft.AspNetCore.Components.Forms)

minimal repro: https://github.com/rlyme/ValidationStackingRepro

  • hit the "toggle visibility" button some times
  • click submit
    --> multiple validation messages "The Summary field is required." are displayed

ASP.NET Core version: 5.0

Metadata

Metadata

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions