Skip to content

Commit

Permalink
chore: disable add new field on field array when Max items is achieved
Browse files Browse the repository at this point in the history
  • Loading branch information
luizakp committed Feb 5, 2024
1 parent 7ecb5ae commit 0654ea4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/FormBuilder/fields/FieldArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,15 @@ export const FieldArray = withConditional<FieldArrayFieldProps>(
</ul>
</DragDropContext>
</div>
<Button type="button" onClick={handleAppend} className="mt-3">
<Button
type="button"
onClick={handleAppend}
className="mt-3"
disabled={
field?.length?.maximum !== undefined &&
fields.length >= field?.length?.maximum
}
>
Add {field.label}
</Button>
</div>
Expand Down

0 comments on commit 0654ea4

Please sign in to comment.