Fix IdAttributeValue generation in interactive mode#65263
Merged
ilonatommy merged 5 commits intodotnet:mainfrom Feb 5, 2026
Merged
Fix IdAttributeValue generation in interactive mode#65263ilonatommy merged 5 commits intodotnet:mainfrom
ilonatommy merged 5 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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 inInputBase<TValue> - Modified
IdAttributeValueto independently generate the field name whenNameAttributeValuereturns empty (interactive mode) - Added tests to verify
idattribute 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 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Jan 30, 2026
Open
pavelsavara
reviewed
Feb 4, 2026
pavelsavara
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Previously,
IdAttributeValuerelied only onNameAttributeValuewhich 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
NameAttributeValueis not always generated.While it makes sense for
nameto be generated only in SSR for form submission (interactivity relies on binding there), we needidto 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).