Skip to content

feat: add Ignore and Only and PreventDefault parameters to global FluentKeyProvider #4519

@MarvinKlein1508

Description

@MarvinKlein1508

🙋 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

  1. Use the FluentKeyCode component directly on the page which is limited because the element needs to be within the FluentKeyCode area and it needs to have an active focus
  2. Provide FluentKeyCode on MainLayout.razor and register events on a per page basis like this:
Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new featurev5For the next major version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions