This is a migrated thread and some comments may be shown as answers.

Set UI Focus in Net5.0

1 Answer 1210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Veteran
Graham asked on 02 Dec 2020, 02:36 PM

Will Telerik Blazor components support this new functionality in the future?

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.elementreferenceextensions.focusasync?view=aspnetcore-5.0#Microsoft_AspNetCore_Components_ElementReferenceExtensions_FocusAsync_Microsoft_AspNetCore_Components_ElementReference_

Set UI focus in Blazor apps
    
Blazor now has a FocusAsync convenience method on ElementReference for setting the UI focus on that element.

<button @onclick="() => textInput.FocusAsync()">Set focus</button><input @ref="textInput"/>

1 Answer, 1 is accepted

Sort by
0
Svetoslav Dimitrov
Telerik team
answered on 04 Dec 2020, 11:23 AM

Hello Graham,

The main difference between the references to our components and the default ElementReference that comes from the framework is that ours are classes, whereas the ElementReference is a struct. The class cannot inherit a struct and that is the reason why ours do not support the FocusAsync method of the ElementReference straight away. Another reason why we do not currently support this is that not all of our components are focusable by default, for example, the Grid container is not focusable, so its reference should not support this feature (the grid cells are, but not the main container). There is no defined list of focusable HTML elements, but I could offer a list of elements that are known to be.

Focusable elements

  • HTMLInputElement (comparable to all our inputs - TextBox, NumericTextBox, DateInput, etc.)
  • HTMLSelectElement (comparable to the DropDownList)
  • HTMLTextAreElement (comparable to the TextArea component)
  • HTMLAnchorElement - focusable if they have a href or tabindex attributes
  • HTMLButtonElement (comparable to the TelerikButton)
  • HTMLAreaElement - focusable if it has the tabindex attribute

That being said, I have opened a new Feature Request on our public Feedback Portal, which you could see from this link. I have added your Vote for it, and since I opened it on your behalf you are automatically subscribed for email notification on status updates. 

Regards,
Svetoslav Dimitrov
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/.

Tags
General Discussions
Asked by
Graham
Top achievements
Rank 1
Veteran
Answers by
Svetoslav Dimitrov
Telerik team
Share this question
or