fix: array minRow validation should not show when non-required with no rows (#12037)

### What?
UI only issue: An array row with `required: false` and `minRows: x` was
displaying an error banner - this should only happen if one or more rows
are present.

The validation is not affected, the document still saved as expected,
but the error should not be inaccurately displayed.

### Why?
The logic for displaying the `minRow` validation error was `rows.length
> minRows` and it needs to be `rows.length > 1 && rows.length > minRows`

### How?
Updates the UI logic.

Fixes #12010
This commit is contained in:
Jessica Chowdhury
2025-04-08 14:47:29 +01:00
committed by GitHub
parent b809c98966
commit f079eced8a

View File

@@ -201,7 +201,7 @@ export const ArrayFieldComponent: ArrayFieldClientComponent = (props) => {
const fieldHasErrors = submitted && errorPaths.length > 0
const showRequired = (readOnly || disabled) && rows.length === 0
const showMinRows = rows.length < minRows || (required && rows.length === 0)
const showMinRows = (rows.length && rows.length < minRows) || (required && rows.length === 0)
return (
<div