Skip to content

Combine ValidationSummary class attribute with custom classes#66364

Closed
KitKeen wants to merge 3 commits into
dotnet:mainfrom
KitKeen:fix/validation-summary-class-merge
Closed

Combine ValidationSummary class attribute with custom classes#66364
KitKeen wants to merge 3 commits into
dotnet:mainfrom
KitKeen:fix/validation-summary-class-merge

Conversation

@KitKeen

@KitKeen KitKeen commented Apr 19, 2026

Copy link
Copy Markdown

Combine ValidationSummary class attribute with custom classes

Fixes #43860

Problem

Passing a class attribute to <ValidationSummary /> via attribute splatting silently overrode the built-in validation-errors class:

<ValidationSummary class="pt-2" data-test="x" />

Before: <ul class="pt-2" data-test="x"> (validation-errors lost)
After: <ul class="pt-2 validation-errors" data-test="x">

Fix

Use the existing AttributeUtilities.CombineClassNames(...) helper that InputBase, InputRadio, and QuickGrid already use. Splat AdditionalAttributes first, then
add the merged class attribute so ProcessDuplicateAttributes keeps the merged value.

Tests

Added ValidationSummaryTest.cs covering:

  • default class without splatting
  • merge with custom class
  • splatting non-class attributes (data-*)
  • existing optimization: no <ul> when no messages

@KitKeen KitKeen requested a review from a team as a code owner April 19, 2026 08:47
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Apr 19, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2026
KitKeen added 2 commits April 24, 2026 00:51
When a class attribute is supplied to <ValidationSummary /> via
attribute splatting, append it to the built-in validation-errors
class instead of replacing it. This matches the pattern used in
InputBase, InputRadio, and QuickGrid via AttributeUtilities.CombineClassNames.

Fixes dotnet#43860
@KitKeen

KitKeen commented May 20, 2026

Copy link
Copy Markdown
Author

Friendly ping - this small Blazor change (#43860) has been open since April 19 without a reviewer assigned. cc @MackinnonBuck @javiercn - could one of you tag an area owner? Happy to address any feedback.

@ilonatommy

Copy link
Copy Markdown
Member

@KitKeen, thank you for your contribution. According to the previous discussion from #43928 (comment), the behavior of overwrite is by design and expected. It is being discussed also under this PR: #66531.

Let us know under the issue if you see a case when the override is not done correctly.

@ilonatommy ilonatommy closed this May 26, 2026
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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass css class in <ValidationSummary /> to the generated <ul>

3 participants