diff --git a/aspnetcore/blazor/fundamentals/routing.md b/aspnetcore/blazor/fundamentals/routing.md index 91e2a08a19b3..fa7e1f0d4411 100644 --- a/aspnetcore/blazor/fundamentals/routing.md +++ b/aspnetcore/blazor/fundamentals/routing.md @@ -66,6 +66,32 @@ Components support multiple route templates using multiple [`@page` directives]( > [!NOTE] > The doesn't interact with query string values. To work with query strings, see the [Query string and parse parameters](#query-string-and-parse-parameters) section. +::: moniker range=">= aspnetcore-6.0" + +## Focus an element on navigation + +Use the `FocusOnNavigate` component to set the UI focus to an element based on a CSS selector after navigating from one page to another. You can see the `FocusOnNavigate` component in use by the `App` component of an app generated from a Blazor project template. + +`App.razor`: + +```razor + + + + + + + +

Sorry, there's nothing at this address.

+
+
+
+``` + +When the preceding `Router` component navigates to a new page, the `FocusOnNavigate` component sets the focus to the page's top-level header (`

`). This is a common strategy for ensuring that page navigations are announced when using a screen reader. + +::: moniker-end + ## Provide custom content when content isn't found The component allows the app to specify custom content if content isn't found for the requested route. diff --git a/aspnetcore/toc.yml b/aspnetcore/toc.yml index 0c85284b5e92..ce7228617623 100644 --- a/aspnetcore/toc.yml +++ b/aspnetcore/toc.yml @@ -465,6 +465,8 @@ href: blazor/components/cascading-values-and-parameters.md#cascadingvalue-component - name: ErrorBoundary href: blazor/fundamentals/handle-errors.md#error-boundaries + - name: FocusOnNavigate + href: blazor/fundamentals/routing.md#focus-an-element-on-navigation - name: InputCheckbox href: blazor/forms-validation.md#built-in-form-components - name: InputDate