Skip to content

Expose preventScroll on ElementReference.FocusAsync #24852

@uabarahona

Description

@uabarahona

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedaffected-fewThis issue impacts only small number of customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onegood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issueseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions