-
Notifications
You must be signed in to change notification settings - Fork 461
Description
🐛 Bug Report
I've created a custom way to select data into a table (with ctrl and shift modifiers).
I've noticed a performance issue with the OnKeyDown handler.
In my case, the OnKeyDown is repeated too many times as the ctrl key is kept pressed.
💻 Repro or Code Sample
<FluentKeyCode OnKeyDown="@OnKeyDownAsync" OnKeyUp="OnKeyUp" IgnoreModifier="false" tabindex="0"
Only="[KeyCode.Function3, KeyCode.KeyF, KeyCode.Ctrl, KeyCode.Shift]" PreventDefault="true" StopPropagation="true">
.....
private void OnKeyDownAsync(FluentKeyCodeEventArgs args)
{
Debug.WriteLine("OnKeyDown");
if (MultipleSelectEnabled | ShiftModifierEnabled) return;
if (args.Key == KeyCode.Ctrl)
{
MultipleSelectEnabled = true;
}
else if (args.Key == KeyCode.Shift)
{
ShiftModifierEnabled = true;
}
}
🤔 Expected Behavior
I would like a new Option to the FluentKeyCode: "StopRepeat" that will check the standard "Repeat" property. if they both are true, the JS will not execute any C# code.
😯 Current Behavior
The code provided, when ctrl key is pressed, the debug output is this:
14:10:57:631 OnKeyDown
14:10:58:129 OnKeyDown
14:10:58:129 OnKeyDown
14:10:58:129 OnKeyDown
14:10:58:129 OnKeyDown
14:10:58:366 OnKeyDown
14:10:58:366 OnKeyDown
14:10:58:366 OnKeyDown
14:10:58:631 OnKeyDown
14:10:58:631 OnKeyDown
14:10:58:631 OnKeyDown
14:10:58:631 OnKeyDown
and so on
💁 Possible Solution
use:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat
🔦 Context
🌍 Your Environment
- OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
- Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
- .NET and Fluent UI Blazor library Version [e.g. 8.0.2 and 4.4.1]