Repository navigation
[KeyCode] Add Only, Ignore and PreventDefaultOnly to FluentKeyCodeProvider - #5477
NoobMaster (oONoobMasterOo) wants to merge 1 commit into
Conversation
…deProvider The global provider only exposed PreventDefault, which prevents every browser shortcut, including the Escape key used to close dialogs. The filters supported by FluentKeyCode are now available on the provider. Fixes microsoft#4519
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes reuse existing filtering behavior, include regression coverage, and have no identified blocking issues.
No open issues 🎉
What changed in this PR
Exposes existing key filters through FluentKeyCodeProvider, enabling selective global keyboard handling for #4519.
Changes:
- Adds
Only,Ignore, andPreventDefaultOnlyparameters and forwards them toFluentKeyCode. - Adds regression coverage for all three filters.
| File | Description |
|---|---|
| tests/Core/Components/KeyCode/FluentKeyCodeTests.razor | Verifies filter values reach JavaScript registration. |
| src/Core/Components/KeyCode/FluentKeyCodeProvider.razor.cs | Declares the three provider parameters. |
| src/Core/Components/KeyCode/FluentKeyCodeProvider.razor | Forwards filters to the global component. |
Review effort: Balanced
|
Could you please provide a short video showing the issue before the code change, and then the expected behavior after the fix? This will make it easier to clearly see and validate the improvement. |
|
Before (dev): to block F5 with the global provider, the only option is 5477-before.mp4After (this PR): 5477-after.mp4 |
Fixes #4519
FluentKeyCodeProvideronly exposedPreventDefault, which prevents the default action of every key, including theEsckey used to close dialogs. It now also exposes the filters already supported byFluentKeyCode, and passes them to its globalFluentKeyCode:PreventDefaultOnly: prevent the default action for some keys only.Only: listen to these keys only.Ignore: ignore these keys.The issue also suggests passing these options to
KeyCodeService.RegisterListener. That's not possible forPreventDefault: the default action must be prevented synchronously in the browser, before the listeners registered on the server are called. So the options are set on the provider, likePreventDefaulttoday.Unit Tests
Added
FluentKeyCode_Provider_PassesKeyFilters.