Skip to content

Commit 720e8c8

Browse files
committed
fix(pf4): Field-Array no longer shows delete all when maxItems has a value greater than 0
1 parent 3151ceb commit 720e8c8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

packages/pf4-component-mapper/src/field-array/field-array.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ const DynamicArray = ({ ...props }) => {
9595
titleDescription={description}
9696
actions={
9797
<React.Fragment>
98-
<Button
99-
variant="link"
100-
isDisabled={value.length === 0}
101-
{...(value.length !== 0 && { onClick: () => removeBatch(value.map((_, index) => index)) })}
102-
>
103-
{combinedButtonLabels.removeAll}
104-
</Button>
98+
{minItems > 0 ? (
99+
''
100+
) : (
101+
<Button
102+
variant="link"
103+
isDisabled={value.length === 0}
104+
{...(value.length !== 0 && {onClick: () => removeBatch(value.map((_, index) => index))})}
105+
>
106+
{combinedButtonLabels.removeAll}
107+
</Button>
108+
)}
105109
<Button
106110
variant="secondary"
107111
isDisabled={value.length >= maxItems}

packages/pf4-component-mapper/src/tests/field-array.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe('<FieldArray/>', () => {
306306
});
307307

308308
await act(async () => {
309-
wrapper.find('button').at(1).simulate('click');
309+
wrapper.find('button').at(0).simulate('click');
310310
});
311311
wrapper.update();
312312

@@ -321,7 +321,7 @@ describe('<FieldArray/>', () => {
321321
onSubmit.mockClear();
322322

323323
await act(async () => {
324-
wrapper.find('button').at(1).simulate('click');
324+
wrapper.find('button').at(0).simulate('click');
325325
});
326326
wrapper.update();
327327

@@ -336,7 +336,7 @@ describe('<FieldArray/>', () => {
336336
onSubmit.mockClear();
337337

338338
await act(async () => {
339-
wrapper.find('button').at(1).simulate('click');
339+
wrapper.find('button').at(0).simulate('click');
340340
});
341341
wrapper.update();
342342

0 commit comments

Comments
 (0)