-
Notifications
You must be signed in to change notification settings - Fork 464
Description
🙋 Feature Request
When using the global FluentKeyProvider approach then you are very limited in it's use-case.
https://fluentui-blazor-v5.azurewebsites.net/KeyCode
You can set PreventDefault="true" but this will prevent all native shortcuts and even FluentUI Blazor features like closing dialogs with ESC key.
You might want to setup some global keycodes which should be prevented by default and the logic for them needs to implemented on a per page basis.
This is currently not possible. You can only achieve this behaviour by either
- Use the
FluentKeyCodecomponent directly on the page which is limited because the element needs to be within theFluentKeyCodearea and it needs to have an active focus - Provide
FluentKeyCodeonMainLayout.razorand register events on a per page basis like this:
Which introduces a lot of boilterplate and hard to manage code for the developer.
💁 Possible Solution
When using KeyCodeService.RegisterListener(this); we could pass in options like PreventDefault, Ignore and Only parameters like in FluentKeyCode
🔦 Context
This issue can be seen in live action the v4 branch as well https://www.fluentui-blazor.net/ press / to trigger search but then you see that the / will be within the input as well. When using PreventDefault on the FluentKeyProvider then literally all component functionality which is based on KeyCode will stop working because it will be prevented.
💻 Examples
I have crafted together this v5 sample app.
https://github.com/MarvinKlein1508/KeyCodeV5