Skip to content

Blazor Identity LoginWith2fa "Remember this machine" checkbox label has a for that matches no element #67669

Description

@javiercn

The Blazor Web App (Individual auth) two-factor login page wraps the "Remember this machine" checkbox in a <label> that carries for="remember-machine", but nothing on the page has id="remember-machine". Because the label declares a for, the browser does not fall back to the implicit wrapping association, so the checkbox ends up with no associated label: screen readers announce an unlabeled checkbox and clicking the visible text does not toggle it.

Source: src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Account/Pages/LoginWith2fa.razor (the <div class="checkbox mb-3"> block).

<label for="remember-machine" class="form-label">
    <InputCheckbox @bind-Value="Input.RememberMachine" />
    Remember this machine
</label>

The InputCheckbox renders name="Input.RememberMachine" and id Input_RememberMachine, never remember-machine.

Expected

The visible "Remember this machine" text labels the checkbox, so an accessible-name lookup finds the control and clicking the text toggles it. The Login page's "Remember me" checkbox already does this correctly with a wrapping label and no for:

<label class="form-label">
    <InputCheckbox @bind-Value="Input.RememberMe" class="darker-border-checkbox form-check-input" />
    Remember me
</label>

Actual

for="remember-machine" resolves to no element, so the checkbox has no accessible name.

Steps to reproduce

  1. Create a Blazor Web App with Individual auth (Server or Auto interactivity).
  2. Register and confirm a user, enable authenticator 2FA.
  3. Log out, log in, reach /Account/LoginWith2fa.
  4. Try to locate the checkbox by its label (for example Playwright GetByLabel("Remember this machine")): it is not found.

Suggested fix

Remove for="remember-machine" (matching Login.razor's "Remember me"), or add id="remember-machine" to the InputCheckbox.

Build validated

Branch main, build 20260630.1, SDK 11.0.100-preview.7.26330.101, ASP.NET Core packages 11.0.0-preview.7.26330.101.

A search for remember-machine and Remember this machine found no existing issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions