EditForm
element rerenders it's child content when model changes. As a side effect, the active (focused) input element is removed from DOM and focus is lost.
<EditForm Model="model">
<!-- Focus will not be retained when model changes -->
<InputText @bind-Value="model.Name" />
...dozen of other inputs
</EditForm>
See demonstration: https://blazorrepl.com/repl/mbbEcJaB56u8TmG400
When the EditForm is rerendred I would like to retain focus on the same input - whatever input had the focus.
How can I retain focus on the same input when EditForm is rerendered?
I would ideally have a generic solution since I there are many forms with many various inputs in my projects
EDIT:
I know how to set focus to an element programmatically, either by using ElementRef.Focus()
or JS.
This question is about keeping focus in whatever input was focused by user.