Skip to content

FocusOnNavigate does not work (dotnet8 - BlazorWebApp) #52412

@ZANZAAA

Description

@ZANZAAA

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The user's scrolling position will be maintained when navigating to a new page.
The <h1> element does not have the focus.

Even though

  • <FocusOnNavigate RouteData="@routeData" Selector="h1" /> is correctly set
  • The pages have a h1 HTML tag

Expected Behavior

After navigating from one page to another, sets focus to an element matching a CSS selector.
Source

Steps To Reproduce

  1. Create a new project using the new Blazor Web App template.
  2. Add some content to the sample pages (Home, Counter, Weather) so users need to scroll to get to the bottom of it.
<br />
<div style="height:2000px; background-color:bisque"></div>
<br />
  1. Once at the bottom bottom of the page, use the menu on the left to navigate to a different page.
  2. The user will remain at their current scrolling position. The focus is not set on the <h1> element.

Exceptions (if any)

No response

.NET Version

8

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Complete Blazor WebPriority:1Work that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-templates

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions