fix: refactors toast error rendering (#13252)

Fixes #13191

- Render a single html element for single error messages
- Preserve ul structure for multiple errors
- Updates tests to check for both cases
This commit is contained in:
Sean Zubrickas
2025-07-28 05:59:25 -07:00
committed by GitHub
parent 2e9ba10fb5
commit d093bb1f00
2 changed files with 27 additions and 18 deletions

View File

@@ -63,11 +63,15 @@ export function FieldErrorsToast({ errorMessage }) {
<div>
{message}
{Array.isArray(errors) && errors.length > 0 ? (
<ul data-testid="field-errors">
{errors.map((error, index) => {
return <li key={index}>{error}</li>
})}
</ul>
errors.length === 1 ? (
<span data-testid="field-error">{errors[0]}</span>
) : (
<ul data-testid="field-errors">
{errors.map((error, index) => {
return <li key={index}>{error}</li>
})}
</ul>
)
) : null}
</div>
)