Very slow text input by enabling KeyUp Event to TextEdit control
Describe the bug Very slow text input by enabling KeyUp Event to TextEdit control
To Reproduce input the text from the keyboard very fast
Example Code In the program Blazor Was application (Blazorise 1.1.2) options.Immediate = false;
private string text { get; set; }
<TextEdit @bind-Text="@text" Placeholder="insert text" KeyUp="OnKeyUp" />
void OnKeyUp(KeyboardEventArgs eventArgs)
{
if (eventArgs.Key == "Enter")
{
//some coding
}
}
Expected behavior the input text must have the same behavior as when KeyUp is not active
This is the expected behavior, although not the one we would want. With the Immediate mode, we can control which event will be used for the input. Either onchange or oninput.
The problem with onkeyup is that there is no alternative. And so, the event will be triggered as soon as you hit the key. Once the EventCallback is invoked the Blazor will handle it and then re-render the UI. Not much we can do here.
It should still not be super slow. Let's take a brief look when possible.
Maybe it has been fixed between the versions, because now - in 1.6.2 - the slow behavior doesn't appear anymore.
<Div>
<Label>WithKeyUp</Label>
<TextEdit Immediate="false" @bind-Text="@text" Placeholder="insert text" KeyUp="OnKeyUp" />
</Div>
<Div>
<Label>No keyUp</Label>
<TextEdit Immediate="false" @bind-Text="@text2" Placeholder="insert text" />
</Div>
@code{
string text = "";
string text2 = "";
void OnKeyUp(KeyboardEventArgs eventArgs)
{
if (eventArgs.Key == "Enter")
{
//some coding
}
}
}
https://github.com/user-attachments/assets/9f002bb7-cd1f-47ab-aa43-e5241505c177
Hello @devrushnet, thank you for your submission. The issue was labeled "Status: Repro Missing", as you have not provided a way to reproduce the issue quickly. Most problems already solve themselves when isolated, but we would like you to provide us with a reproducible code to make it easier to investigate a possible bug.