ValidatorBase: too many StateHasChanged calls #1736

Open
opened 2026-01-29 17:57:52 +00:00 by claunia · 0 comments
Owner

Originally created by @FrankNWB on GitHub (Apr 24, 2025).

Describe the bug
I use the RadzenCustomValidator in many components in my form and since then the performance has become very degraded.
After checking the source code of the ValidatorBase class, I noticed that EditContext?.NotifyValidationStateChanged() is also called for each validation, resulting in ValidationStateChanged() calling StateHasChanged() every time.

To Reproduce
in ValidatorBase, starting at Line 114:
Image

The call to NotifyValidationStateChanged results in a call to the event handler:
Image

Expected behavior
StateHasChanged() should only be executed if the IsValid field has actually changed.

Instead of always calling
EditContext?.NotifyValidationStateChanged();

maybe there should be a check before:

Image

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 135
Originally created by @FrankNWB on GitHub (Apr 24, 2025). **Describe the bug** I use the RadzenCustomValidator in many components in my form and since then the performance has become very degraded. After checking the source code of the ValidatorBase class, I noticed that EditContext?.NotifyValidationStateChanged() is also called for each validation, resulting in ValidationStateChanged() calling StateHasChanged() every time. **To Reproduce** in ValidatorBase, starting at Line 114: <img width="629" alt="Image" src="https://github.com/user-attachments/assets/da5635e5-ef8d-4850-9883-f488cedc510b" /> The call to NotifyValidationStateChanged results in a call to the event handler: <img width="490" alt="Image" src="https://github.com/user-attachments/assets/8736c6f9-df62-43bf-86db-6c136ff62878" /> **Expected behavior** StateHasChanged() should only be executed if the IsValid field has actually changed. Instead of always calling EditContext?.NotifyValidationStateChanged(); maybe there should be a check before: <img width="556" alt="Image" src="https://github.com/user-attachments/assets/836100cf-f9c6-46c6-a9dc-bbcf3c48153d" /> **Desktop (please complete the following information):** - OS: Windows - Browser: Chrome - Version: 135
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1736