Hi,
I would like to confirm whether the following behavior is a known issue with the TelerikEditor component. Specifically, I am referring to its ValueChange event as documented on Blazor Editor Events - Telerik UI for Blazor.
Please, use the following code example instead:
@* Provide an initial value and update the view-model through the ValueChanged event *@
<TelerikEditor Value="@TheEditorContent" ValueChanged="@ValueChangedHandler">
</TelerikEditor>
@TheEditorContent
@code {
string TheEditorContent { get; set; } = @"<div>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<p />
<p />
<p>Paragraph 4</p>
</div>";
void ValueChangedHandler(string value)
{
// update the view-model
//TheEditorContent = value;
Console.WriteLine("ValueChanged fired");
}
}
In this example, TheEditorContent string as been assigned a verbatim literal string containing CRLF formatting. The view-model update was commented out.
Compile and, hopefully, you'll confirm as I did that if you click or try to type on the editor, the console will infinitely loop over the ValueChangeHandler and print "ValueChanged fired" indefinitely. Furthermore, if you actually update the view-model, although the loop doesn't occur anymore, the ValueChanged event is fired upon cliking once on the editor. I assume that upon update, the editor changes the formatting of the input in such a way that this "bug" is not longer triggered on further clicks. Why does that happen and how can one fix it?
PS: I noticed this behaviour on my own project, where I wanted to save the original checksum of the text and compare it with successive new checksums as I edited the text in order to check for text differences. Anyway, due to this problem I have a different checksum as soon as I click the editor, thus triggering other logic of mine warning the user that it needs to save his/her changes (although there aren't any).