question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose `preventScroll` on ElementReference.FocusAsync

See original GitHub issue

Add 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:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
KonstantinAlexeevichcommented, Dec 14, 2020

I want to try, if it possible

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found