Skip to content

Commit

Permalink
fix: Add boolean option to allow deletion of first array field templa…
Browse files Browse the repository at this point in the history
…te item
  • Loading branch information
gdalcengio committed Oct 15, 2024
1 parent 18b6cb0 commit 3281fea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const facilityInformationLfoUiSchema: UiSchema = {
label: false,
arrayAddLabel: "Add facility",
title: "Facility",
canDeleteFirst: true,
},
items: {
...facilitiesLfoUiSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const ArrayFieldTemplate = ({
}: ArrayFieldTemplateProps) => {
const arrayAddLabel =
(uiSchema?.["ui:options"]?.arrayAddLabel as string) || "Add";
const canDeleteFirst =
(uiSchema?.["ui:options"]?.canDeleteFirst as boolean) || false;

const customTitleName = uiSchema?.["ui:options"]?.title as string;

Expand All @@ -43,7 +45,7 @@ const ArrayFieldTemplate = ({
{customTitleName} {i + 1}
</span>
)}
{i !== 0 && (
{(i !== 0 || canDeleteFirst) && (
<button
onClick={item.onDropIndexClick(item.index)}
className="border-none bg-transparent p-0 ml-6"
Expand Down

0 comments on commit 3281fea

Please sign in to comment.