Skip to content

Combine ValidationSummary class attribute with custom classes#66364

Open
KitKeen wants to merge 2 commits intodotnet:mainfrom
KitKeen:fix/validation-summary-class-merge
Open

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

Conversation

@KitKeen
Copy link
Copy Markdown

@KitKeen KitKeen commented Apr 19, 2026

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
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Thanks for your PR, @KitKeen. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

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
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>

1 participant