Expose `preventScroll` on ElementReference.FocusAsync
See original GitHub issueAdd an overload to ElementReference.FocusAsync that accepts preventScroll
as an option:
public static ValueTask FocusAsync(this ElementReference elementReference, bool preventScroll);
I should probably add a new issue for this but I think FocusAsync() should also include preventScroll
flag
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus
Describe the bug
On Blazor server side, when you apply autofocus on your inputs the attribute is not being respected:
- At the first time, you can see the
autofocus
being applied but loses it after the page fully load - When you use the navigation bar the
autofocus
is not applied at all
To Reproduce
Create a page with the followin code:
<input type="text" name="name" />
<input type="text" name="name1" autofocus />
Expected: If you don’t do anything while the page loads the autofocus must be aplied
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
ElementReferenceExtensions.FocusAsync Method
Gives focus to an element given its ElementReference. ... FocusAsync(ElementReference) ... ElementReference elementReference, bool preventScroll);
Read more >Blazor's FocusAsync doesn't always set focus
I can't make .NET 6's Blazor AsyncFocus method work. Near as I can tell, AsyncFocus only works when a component value isn't null....
Read more >https://raw.githubusercontent.com/microsoft/fluent...
... `FocusTrapZone` prop `preventScrollOnRestoreFocus` to prevent scroll on focus ... Fix `Animation` to expose `Transition` state for the consumer @chpalac ...
Read more >Blazor .NET 5 - Easy Focus with FocusAsync (No ... - YouTube
Link to the course: https://www.udemy.com/course/programming-in-blazor-aspnet-core/?referralCode=8EFA9D9FF38E3065DF0C In this video we'll ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Done in https://github.com/dotnet/aspnetcore/pull/28686
I want to try, if it possible