Skip to content

Blazor Identity components don't specify id for labels #53266

Open
@guardrex

Description

@guardrex

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The <label> spec (4.10.4) calls for explicitly-labeled elements to have an id that matches the <label>'s for attribute. The Identity components don't have id set.

For example, the InputText component of the Login component doesn't set id="email" to match the <label>'s for attribute ...

<div class="form-floating mb-3">
    <InputText @bind-Value="Input.Email" class="form-control" autocomplete="username" aria-required="true" placeholder="[email protected]" />
    <label for="email" class="form-label">Email</label>
    <ValidationMessage For="() => Input.Email" class="text-danger" />
</div>

Rendered ...

<div class="form-floating mb-3">
    <input autocomplete="off" aria-required="true" placeholder="[email protected]" name="Input.Email" class="form-control valid" value="" style="background-image: url(&quot;moz-extension://dcb55c96-de40-4f2c-913f-d37cccad5aae/images/web_access/vault-input-disabled.svg&quot;) !important; background-repeat: no-repeat !important; background-position: calc(100% - 3px) center !important; background-size: 14px !important; cursor: text;">
    <label for="email" class="form-label">Email</label>
</div>

Therefore, the control and form properties are null ...

image

When the InputText element is provided with id="email", the form and control properties are set ...

image

Expected Behavior

InputText elements (and any other labeled elements) have an id matching the for attribute of label elements.

Steps To Reproduce

None ... it's a template thing.

Exceptions (if any)

None ... the labels just no-op.

.NET Version

8.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Technical DebtPriority: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

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions