Skip to content

Commit ea32863

Browse files
committed
Address review comments on SimpleFormIterator fix
1 parent b7459b1 commit ea32863

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIterator.spec.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,11 @@ describe('<SimpleFormIterator />', () => {
570570
).toEqual(['101', '102', '103']);
571571
});
572572

573+
const lastItem = screen
574+
.queryAllByLabelText('Venue')[2]
575+
.closest('li') as HTMLElement;
573576
const removeLastButton = getByLabelText(
574-
// @ts-ignore
575-
screen.queryAllByLabelText('Venue')[2].closest('li'),
577+
lastItem,
576578
'ra.action.remove'
577579
).closest('button') as HTMLButtonElement;
578580

@@ -650,9 +652,11 @@ describe('<SimpleFormIterator />', () => {
650652
</Wrapper>
651653
);
652654

655+
const firstItem = screen
656+
.queryAllByLabelText('Venue')[0]
657+
.closest('li') as HTMLElement;
653658
const removeFirstButton = getByLabelText(
654-
// @ts-ignore
655-
screen.queryAllByLabelText('Venue')[0].closest('li'),
659+
firstItem,
656660
'ra.action.remove'
657661
).closest('button') as HTMLButtonElement;
658662

packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIterator.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
22
import type { ReactNode } from 'react';
3-
import { useWatch } from 'react-hook-form';
43
import {
54
type ComponentsOverrides,
65
styled,
@@ -64,10 +63,7 @@ export const SimpleFormIterator = (inProps: SimpleFormIteratorProps) => {
6463
}
6564
const { fields } = useArrayInput(props);
6665
const record = useRecordContext(props);
67-
const records =
68-
useWatch({
69-
name: finalSource,
70-
}) ?? get(record, finalSource);
66+
const records = get(record, finalSource);
7167
const getArrayInputNewItemDefaults =
7268
useGetArrayInputNewItemDefaults(fields);
7369

0 commit comments

Comments
 (0)