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..f9d0dd0d7f0 100644 --- a/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx +++ b/packages/ra-ui-materialui/src/input/SelectArrayInput.stories.tsx @@ -167,6 +167,20 @@ export const Disabled = () => ( ); +export const DisabledChoice = () => ( + + + +); + export const ReadOnly = () => ( ', () => { ).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( diff --git a/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx b/packages/ra-ui-materialui/src/input/SelectInput.stories.tsx index 5046f3a6ea3..40e9bef4507 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 }) => (