Last Updated: 04 Jan 2021 08:29 by ADMIN
Created on: 16 Dec 2020 08:14
Category: UI for Blazor
Type: Feature Request
Focus events for Inputs



Since the focus events are natively supported by blazor, could they be implemented in the input controls? Workarounds via JS are possible but they create a lot of redundant and cluttered code around the code base. OnChange/ValueChange only fire when the value has changed. Though, we have a lot of scenarios where we need the focus events when a value did not change.

1 comment
Marin Bratanov
Posted on: 16 Dec 2020 08:25

Hi Srdjan,

The focus method is a new thing in .NET 5 and you can follow its implementation here: https://feedback.telerik.com/blazor/1497943-add-a-focus-method-for-all-applicable-component-references . If that's what you're looking for, Vote for it and Follow it, so we can mark this as a duplicate.

As for handling the variety of DOM events that are possible (such as clicks, focusin, focusout and so on), the following article shows how you can do that: https://docs.telerik.com/blazor-ui/knowledge-base/inputs-handle-keyboard-events. Exposing dozens of events on a component will slow it down immensely, and will cause many re-renders on both the component and its parent and siblings, so it is not something we can do off the bat - for a component those events need to be EventCallbacks which will cause a performance hit.

Another thing that can be useful is the approach from this article on knowing when an input loses focus versus losing focus and having a changed value: https://docs.telerik.com/blazor-ui/knowledge-base/ddl-onchange-fires-twices.

If you are looking for something different than these, could you provide some more details on the scenario and how our components prevent you from achieving it?


Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.