Skip to content

Commit 11fbc6e

Browse files
authored
Merge pull request #8792 from kriskw1999/next_simple_form_iterator
[SimpleFormIterator] default to null instead of empty string
2 parents d5ada68 + c3add6c commit 11fbc6e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/ra-core/src/form/FormDataConsumer.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('FormDataConsumerView', () => {
146146

147147
fireEvent.click(screen.getByLabelText('ra.action.add'));
148148

149-
expect(globalScopedFormData).toEqual({ name: '' });
149+
expect(globalScopedFormData).toEqual({ name: null });
150150

151151
fireEvent.change(
152152
screen.getByLabelText('resources.undefined.fields.authors.name'),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ describe('<SimpleFormIterator />', () => {
770770
await waitFor(() => {
771771
expect(save).toHaveBeenCalledWith(
772772
{
773-
emails: [{ email: '' }],
773+
emails: [{ email: null }],
774774
},
775775
expect.anything()
776776
);
@@ -853,7 +853,7 @@ describe('<SimpleFormIterator />', () => {
853853
expect(save).toHaveBeenCalledWith(
854854
{
855855
id: 1,
856-
emails: [{ email: '', role: '' }],
856+
emails: [{ email: null, role: null }],
857857
},
858858
expect.anything()
859859
);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const SimpleFormIterator = (props: SimpleFormIteratorProps) => {
7575
const { id, ...rest } = fields[0];
7676
initialDefaultValue.current = rest;
7777
for (const k in initialDefaultValue.current)
78-
initialDefaultValue.current[k] = '';
78+
initialDefaultValue.current[k] = null;
7979
}
8080

8181
const addField = useCallback(
@@ -104,7 +104,7 @@ export const SimpleFormIterator = (props: SimpleFormIteratorProps) => {
104104
input.props.source
105105
) {
106106
defaultValue[input.props.source] =
107-
input.props.defaultValue ?? '';
107+
input.props.defaultValue ?? null;
108108
}
109109
});
110110
}

0 commit comments

Comments
 (0)