Skip to content

Conversation

@ilonatommy
Copy link
Member

Background

Previously, IdAttributeValue relied only on NameAttributeValue which returns empty in interactive mode. Now it falls back to generating the field name directly when needed.

When implementing #64821 we missed the point that NameAttributeValue is not always generated.

While it makes sense for name to be generated only in SSR for form submission (interactivity relies on binding there), we need id to support the Lable/input association regardless of render mode.

Details

The generation logic common for name and id got moved to a separate method.

Follow up for #64821 (comment).

@ilonatommy ilonatommy added this to the .NET 11 Planning milestone Jan 29, 2026
@ilonatommy ilonatommy self-assigned this Jan 29, 2026
Copilot AI review requested due to automatic review settings January 29, 2026 12:34
@ilonatommy ilonatommy requested a review from a team as a code owner January 29, 2026 12:34
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jan 29, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the id attribute was not being generated for input components in interactive mode (e.g., Blazor WebAssembly or interactive render modes). The id attribute is essential for Label/Input association to work correctly, even when the name attribute is not generated.

Changes:

  • Refactored field name generation logic into a new GetFieldName() method in InputBase<TValue>
  • Modified IdAttributeValue to independently generate the field name when NameAttributeValue returns empty (interactive mode)
  • Added tests to verify id attribute generation in interactive scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Components/Web/src/Forms/InputBase.cs Extracted GetFieldName() method and updated IdAttributeValue to fall back to generating field name independently when needed for interactive mode
src/Components/Web/test/Forms/InputTextTest.cs Added two new tests to verify id attribute generation in interactive mode scenarios

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

ilonatommy and others added 2 commits January 29, 2026 15:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant