RadzenRequiredValidator is not triggered when erasing the content of RadzenHtmlEditor #980

Closed
opened 2026-01-29 17:47:14 +00:00 by claunia · 3 comments
Owner

Originally created by @DanOpcode on GitHub (Sep 9, 2023).

Describe the bug

I am using a RadzenHtmlEditor together with a RadzenRequiredValidator. When I type text into the field, leave the field, erase the field's text, and then leave the field again, the validator is not triggered.

To Reproduce

Here is a code sample:

@using Radzen.Blazor
@using Radzen

@page "/"

<RadzenTemplateForm TItem="Person" Data=@model Submit=@OnSubmit>
    <p>
        <RadzenLabel Component="FirstName" Text="First name" />
        <RadzenTextBox Name="FirstName" @bind-Value=@model.FirstName />
        <RadzenRequiredValidator Component="FirstName" Text="First name is required!" />
    </p>
    <p>
        <RadzenLabel Component="Text" Text="Text" />
        <RadzenHtmlEditor Name="Text" @bind-Value=@model.Text />
        <RadzenRequiredValidator Component="Text" Text="Text is required!" />
    </p>
    <RadzenButton ButtonType="ButtonType.Submit" Text="Save" />
</RadzenTemplateForm>

@code {
    class Person
    {
        public string FirstName { get; set; }
        public string Text { get; set; }
    }

    Person model = new Person();

    void OnSubmit(Person person)
    {
    }
}

Steps to reproduce the behavior:

  1. Type text into the HTML field.
  2. Leave the field, so it loses its focus.
  3. Erase the HTML field's content.
  4. Leave the field, so it loses its focus.
  5. No error appears about the field being required.

Expected behavior

In step 5, I expect the RadzenRequiredValidator to run and show its error message.

These exact same steps work for a RadzenTextBox.

Screenshots

Here is a screen recording of me doing the steps above, first with a HTML field and then for a text field:

https://github.com/radzenhq/radzen-blazor/assets/980838/5158210c-78d7-409e-b8d7-26469aba9c48

Here is a screenshot of what it looks like in the end:

image

As you can see, the required validator is triggered for the text field, but not for the HTML field.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Firefox
  • Version: 117

Additional context

N/A

Originally created by @DanOpcode on GitHub (Sep 9, 2023). ### Describe the bug I am using a `RadzenHtmlEditor` together with a `RadzenRequiredValidator`. When I type text into the field, leave the field, erase the field's text, and then leave the field again, the validator is not triggered. ### To Reproduce Here is a code sample: ```razor @using Radzen.Blazor @using Radzen @page "/" <RadzenTemplateForm TItem="Person" Data=@model Submit=@OnSubmit> <p> <RadzenLabel Component="FirstName" Text="First name" /> <RadzenTextBox Name="FirstName" @bind-Value=@model.FirstName /> <RadzenRequiredValidator Component="FirstName" Text="First name is required!" /> </p> <p> <RadzenLabel Component="Text" Text="Text" /> <RadzenHtmlEditor Name="Text" @bind-Value=@model.Text /> <RadzenRequiredValidator Component="Text" Text="Text is required!" /> </p> <RadzenButton ButtonType="ButtonType.Submit" Text="Save" /> </RadzenTemplateForm> @code { class Person { public string FirstName { get; set; } public string Text { get; set; } } Person model = new Person(); void OnSubmit(Person person) { } } ``` Steps to reproduce the behavior: 1. Type text into the HTML field. 2. Leave the field, so it loses its focus. 3. Erase the HTML field's content. 4. Leave the field, so it loses its focus. 5. No error appears about the field being required. ### Expected behavior In step 5, I expect the `RadzenRequiredValidator` to run and show its error message. These exact same steps work for a `RadzenTextBox`. ### Screenshots Here is a screen recording of me doing the steps above, first with a HTML field and then for a text field: https://github.com/radzenhq/radzen-blazor/assets/980838/5158210c-78d7-409e-b8d7-26469aba9c48 Here is a screenshot of what it looks like in the end: ![image](https://github.com/radzenhq/radzen-blazor/assets/980838/572eec0f-6e0d-466b-90fe-9cf999353f37) As you can see, the required validator is triggered for the text field, but not for the HTML field. ### Desktop (please complete the following information): - OS: Windows 11 - Browser: Firefox - Version: 117 ### Additional context N/A
Author
Owner

@akorchev commented on GitHub (Sep 9, 2023):

There is probably some invisible content in the HTML editor - you can check the source view (the <> button). If there is then the required validator will not trigger.

@akorchev commented on GitHub (Sep 9, 2023): There is probably some invisible content in the HTML editor - you can check the source view (the <> button). If there is then the required validator will not trigger.
Author
Owner

@tiagoserra commented on GitHub (Jul 17, 2024):

While analyzing my development environment, I noticed an issue, which I will detail in the following steps:

1 - Copy something from a website (text)
2 - Paste it
3 - Delete all the text
4 - Placed a breakpoint on the Change event (HtmlEditorPasteEventArgs) and checked the HTML:
<br><ul></ul><ul></ul>

I believe the problem occurs when all the text is deleted, but the HTML tags remain as "ghosts", thus not passing through the validator.

ev2
en1

@tiagoserra commented on GitHub (Jul 17, 2024): While analyzing my development environment, I noticed an issue, which I will detail in the following steps: 1 - Copy something from a website (text) 2 - Paste it 3 - Delete all the text 4 - Placed a breakpoint on the Change event (HtmlEditorPasteEventArgs) and checked the HTML: `<br><ul></ul><ul></ul>` I believe the problem occurs when all the text is deleted, but the HTML tags remain as "ghosts", thus not passing through the validator. ![ev2](https://github.com/user-attachments/assets/452af971-1dde-4525-914d-ea1cbd7d2203) ![en1](https://github.com/user-attachments/assets/46f732c5-8f25-4d19-a596-c537046f5298)
Author
Owner

@akorchev commented on GitHub (Mar 1, 2025):

I am afraid we can't do anything to affect the built-in HTML editing behavior of the browser. It is known to leave content during editing.

@akorchev commented on GitHub (Mar 1, 2025): I am afraid we can't do anything to affect the built-in HTML editing behavior of the browser. It is known to leave content during editing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#980