From 27f440c1616b0c686d984ca3dca4ac7dd1ff9fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Svarcas?= Date: Mon, 7 Jul 2025 16:46:35 -0300 Subject: [PATCH 1/5] Add test --- .../src/input/SelectInput.spec.tsx | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx b/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx index 39fcb2303dd..669b3e70918 100644 --- a/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx +++ b/packages/ra-ui-materialui/src/input/SelectInput.spec.tsx @@ -79,7 +79,7 @@ describe('', () => { ).toEqual('rea'); }); - it('should render disabled choices marked so', () => { + it('should render disabled choices marked as so', () => { render( @@ -111,6 +111,39 @@ describe('', () => { ).toEqual('true'); }); + it('should render disabled choices marked as so by disableValue prop', () => { + render( + + + + + + + + ); + fireEvent.mouseDown( + screen.getByLabelText('resources.posts.fields.language') + ); + + expect( + screen.getByText('Angular').getAttribute('aria-disabled') + ).toBeNull(); + expect( + screen.getByText('React').getAttribute('aria-disabled') + ).toEqual('true'); + }); + it('should include an empty option by default', () => { render( From 69bd805b9143994961710b36f5539b333d27b5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Svarcas?= Date: Mon, 7 Jul 2025 16:46:55 -0300 Subject: [PATCH 2/5] Add story --- .../src/input/SelectInput.stories.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx b/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx index 5046f3a6ea3..02b70eb0692 100644 --- a/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx @@ -112,6 +112,19 @@ export const Disabled = () => ( ); +export const DisabledChoice = () => ( + + + +); + export const Variant = ({ hideLabel }) => ( Date: Mon, 7 Jul 2025 17:07:14 -0300 Subject: [PATCH 3/5] improve story --- packages/ra-ui-materialui/src/input/SelectInput.stories.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx b/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx index 02b70eb0692..40e9bef4507 100644 --- a/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx @@ -117,9 +117,9 @@ export const DisabledChoice = () => ( From 2cd797b26826bb11c73522688a50f4b7d37cd61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Svarcas?= Date: Mon, 7 Jul 2025 17:18:38 -0300 Subject: [PATCH 4/5] Add test and story for SelectArrayInput --- .../src/input/SelectArrayInput.spec.tsx | 33 ++++++++++++++++++- .../src/input/SelectArrayInput.stories.tsx | 15 +++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.tsx b/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.tsx index c0e939dc9ae..d53524a73e3 100644 --- a/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.tsx +++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.spec.tsx @@ -228,7 +228,7 @@ describe('', () => { expect(screen.queryByText('Programming')).not.toBeNull(); }); - it('should render disable choices marked so', () => { + it('should render disable choices marked as so', () => { render( @@ -254,6 +254,37 @@ describe('', () => { expect(option2.getAttribute('aria-disabled')).toEqual('true'); }); + it('should render disabled choices marked as so by disableValue prop', () => { + render( + + + + + + + + ); + fireEvent.mouseDown( + screen.getByLabelText('resources.posts.fields.categories') + ); + const option1 = screen.getByText('Angular'); + expect(option1.getAttribute('aria-disabled')).toBeNull(); + + const option2 = screen.getByText('React'); + expect(option2.getAttribute('aria-disabled')).toEqual('true'); + }); + describe('translateChoice', () => { it('should translate the choices by default', async () => { render(); diff --git a/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx b/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx index ca33b548e34..096fa75eee9 100644 --- a/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx @@ -26,6 +26,7 @@ import { ReferenceArrayInput } from './ReferenceArrayInput'; import { SelectArrayInput } from './SelectArrayInput'; import { TextInput } from './TextInput'; import { useCreateSuggestionContext } from './useSupportCreateSuggestion'; +import { SelectInput } from './SelectInput'; export default { title: 'ra-ui-materialui/input/SelectArrayInput' }; @@ -167,6 +168,20 @@ export const Disabled = () => ( ); +export const DisabledChoice = () => ( + + + +); + export const ReadOnly = () => ( Date: Mon, 7 Jul 2025 17:21:43 -0300 Subject: [PATCH 5/5] removed unused import --- packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx b/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx index 096fa75eee9..f9d0dd0d7f0 100644 --- a/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx @@ -26,7 +26,6 @@ import { ReferenceArrayInput } from './ReferenceArrayInput'; import { SelectArrayInput } from './SelectArrayInput'; import { TextInput } from './TextInput'; import { useCreateSuggestionContext } from './useSupportCreateSuggestion'; -import { SelectInput } from './SelectInput'; export default { title: 'ra-ui-materialui/input/SelectArrayInput' };