diff --git a/packages/ra-core/src/controller/input/ReferenceArrayInputBase.stories.tsx b/packages/ra-core/src/controller/input/ReferenceArrayInputBase.stories.tsx
index 8194fb65fb3..59cfe02f71e 100644
--- a/packages/ra-core/src/controller/input/ReferenceArrayInputBase.stories.tsx
+++ b/packages/ra-core/src/controller/input/ReferenceArrayInputBase.stories.tsx
@@ -8,8 +8,7 @@ import { CreateBase } from '../../controller/create/CreateBase';
import { testDataProvider } from '../../dataProvider/testDataProvider';
import { DataProvider } from '../../types';
import { Form } from '../../form/Form';
-import { useInput } from '../../form/useInput';
-import { InputProps } from '../../form/types';
+import { InputProps, useInput } from '../../form/useInput';
import { TestMemoryRouter } from '../../routing/TestMemoryRouter';
import {
ReferenceArrayInputBase,
diff --git a/packages/ra-core/src/controller/input/ReferenceArrayInputBase.tsx b/packages/ra-core/src/controller/input/ReferenceArrayInputBase.tsx
index 20772908911..4d1d95dc809 100644
--- a/packages/ra-core/src/controller/input/ReferenceArrayInputBase.tsx
+++ b/packages/ra-core/src/controller/input/ReferenceArrayInputBase.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { InputProps } from '../../form/types';
+import { InputProps } from '../../form/useInput';
import {
useReferenceArrayInputController,
type UseReferenceArrayInputParams,
diff --git a/packages/ra-core/src/form/types.ts b/packages/ra-core/src/form/types.ts
deleted file mode 100644
index 3304c834938..00000000000
--- a/packages/ra-core/src/form/types.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export interface InputProps {
- addField?: boolean;
- defaultValue?: any;
- input?: any;
- source: string;
-}
diff --git a/packages/ra-ui-materialui/src/input/ReferenceArrayInput.spec.tsx b/packages/ra-ui-materialui/src/input/ReferenceArrayInput.spec.tsx
index 7815bdec371..38b57af690a 100644
--- a/packages/ra-ui-materialui/src/input/ReferenceArrayInput.spec.tsx
+++ b/packages/ra-ui-materialui/src/input/ReferenceArrayInput.spec.tsx
@@ -22,7 +22,7 @@ import { DatagridInput } from './DatagridInput';
import { TextField } from '../field';
import { ReferenceArrayInput } from './ReferenceArrayInput';
import { SelectArrayInput } from './SelectArrayInput';
-import { DifferentIdTypes } from './ReferenceArrayInput.stories';
+import { AsFilters, DifferentIdTypes } from './ReferenceArrayInput.stories';
describe('', () => {
const defaultProps = {
@@ -292,4 +292,15 @@ describe('', () => {
})
).toBeNull();
});
+
+ it('can be used as a list filter', async () => {
+ render();
+ await screen.findByText('band_2');
+ fireEvent.click(screen.getByText('Members'));
+ fireEvent.click(screen.getByText('artist_2'));
+ await waitFor(() => {
+ expect(screen.queryByText('band_2')).toBeNull();
+ });
+ await screen.findByText('band_1');
+ });
});
diff --git a/packages/ra-ui-materialui/src/input/ReferenceArrayInput.stories.tsx b/packages/ra-ui-materialui/src/input/ReferenceArrayInput.stories.tsx
index d50c2ef1d56..4787a02cc72 100644
--- a/packages/ra-ui-materialui/src/input/ReferenceArrayInput.stories.tsx
+++ b/packages/ra-ui-materialui/src/input/ReferenceArrayInput.stories.tsx
@@ -20,6 +20,7 @@ import { ReferenceArrayInput } from './ReferenceArrayInput';
import { AutocompleteArrayInput } from './AutocompleteArrayInput';
import { SelectArrayInput } from './SelectArrayInput';
import { CheckboxGroupInput } from './CheckboxGroupInput';
+import { List, Datagrid } from '../list';
export default { title: 'ra-ui-materialui/input/ReferenceArrayInput' };
@@ -77,6 +78,51 @@ export const Basic = () => (
);
+export const AsFilters = () => {
+ const fakeData = {
+ bands: [
+ { id: 1, name: 'band_1', members: [2] },
+ { id: 2, name: 'band_2', members: [3] },
+ ],
+ artists: [
+ { id: 1, name: 'artist_1' },
+ { id: 2, name: 'artist_2' },
+ { id: 3, name: 'artist_3' },
+ ],
+ };
+ return (
+
+
+
+
+ (
+
,
+ ]}
+ >
+
+
+
+
+ )}
+ />
+
+
+
+ );
+};
+
export const WithAutocompleteInput = () => (