mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
refactor(field): no duplicate errors (#8514)
* chore: tweaks > field.tsx apps/v4/registry/new-york-v4/ui/field.tsx * chore: tweaks > field.tsx apps/v4/registry/new-york-v4/ui/field.tsx * chore: tweaks > field.json field.json apps/www/public/r/styles/new-york-v4/field.json apps/v4/public/r/styles/new-york-v4/field.json
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -200,13 +200,17 @@ function FieldError({
|
||||
return null
|
||||
}
|
||||
|
||||
if (errors?.length == 1) {
|
||||
return errors[0]?.message
|
||||
const uniqueErrors = [
|
||||
...new Map(errors.map((error) => [error?.message, error])).values(),
|
||||
]
|
||||
|
||||
if (uniqueErrors?.length == 1) {
|
||||
return uniqueErrors[0]?.message
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="ml-4 flex list-disc flex-col gap-1">
|
||||
{errors.map(
|
||||
{uniqueErrors.map(
|
||||
(error, index) =>
|
||||
error?.message && <li key={index}>{error.message}</li>
|
||||
)}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user