radzenhq / radzen-blazor

Radzen Blazor is a set of 70+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.36k stars 758 forks source link

Allow custom event onkeydown handlers for all input components #1584

Open standbych opened 2 weeks ago

standbych commented 2 weeks ago

Describe the bug It's not possible to use any custom onkeydown handlers anymore, because of the @onkeydown:stopPropagation added for https://github.com/radzenhq/radzen-blazor/pull/1379.

To Reproduce Steps to reproduce the behavior:

  1. Add a RadzenNumberic component
  2. Add @onkeydown event handler
  3. run and press any key in the component (the event handler does not get called)

Demo project: https://github.com/standbych/radzen-keypress

Expected behavior It should be possible to add custom event handlers or at least make the behaviour configurable.

enchev commented 2 weeks ago

I don't think we should do that. If we allow keydown propagation the internal handling of keyboard events in complex nested components like DataGrid will become nightmare. Key events from the Numeric will clash with keyboard navigation in the DataGrid, etc. Maybe introducing separate KeyDown event for such components will be a better option, still I'm not sure why you need it.

standbych commented 2 weeks ago

I'd like to have some custom event handling for some keys like "Enter", "Escape" to move forward or reset the value. The behaviour has worked before, but now I'm stuck with version 4.23.9 - before the stopPropagation was set. A separate KeyDown event is not that intuitive, but still better than nothing. Wouldn't it be possible to set a CascadingValue in the DataGrid to set the stopPropagation value in the input components? Or a simple parameter which disables the stopPropagation? The event handling works great for e.g. TextBox, but not Numeric and others anymore...