Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/ra-ui-materialui/src/field/ArrayField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ describe('<ArrayField />', () => {
);
});

it('should accept label prop (FieldProps)', () => {
// This test ensures that ArrayField accepts the label prop from FieldProps
// Regression test for https://github.com/marmelab/react-admin/issues/11197
render(
<Wrapper>
<ArrayField
source="arr"
label="My Array"
record={{ id: 123, arr: [{ id: 1, foo: 'bar' }] }}
>
<DummyIterator />
</ArrayField>
</Wrapper>
);
});

it('should not fail when value is null', () => {
render(
<Wrapper>
Expand Down
5 changes: 4 additions & 1 deletion packages/ra-ui-materialui/src/field/ArrayField.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { ArrayFieldBase, type ArrayFieldBaseProps } from 'ra-core';

import type { FieldProps } from './types';
Expand All @@ -23,7 +24,9 @@ import type { FieldProps } from './types';
*
* @see useListContext
*/
export const ArrayField = ArrayFieldBase;
export const ArrayField = ArrayFieldBase as unknown as <
RecordType extends Record<string, any> = Record<string, any>,
>(props: ArrayFieldProps<RecordType>) => React.ReactElement;

export interface ArrayFieldProps<
RecordType extends Record<string, any> = Record<string, any>,
Expand Down