diff --git a/packages/mui-material/src/Select/Select.test.js b/packages/mui-material/src/Select/Select.test.js index a7f5dd963ba7c0..a2aebe345ce4db 100644 --- a/packages/mui-material/src/Select/Select.test.js +++ b/packages/mui-material/src/Select/Select.test.js @@ -474,6 +474,12 @@ describe('); + + expect(getByRole('combobox')).not.to.have.attribute('aria-required'); + }); + it('sets required attribute in input when component is required', () => { const { container } = render(', () => { expect(getByRole('combobox')).to.have.attribute('aria-invalid', 'true'); }); + it('aria-invalid is not present if component is not in an error state', () => { + const { getByRole } = render(); diff --git a/packages/mui-material/src/Select/SelectInput.js b/packages/mui-material/src/Select/SelectInput.js index 2f5ed36db4f675..fd48bd5d44b08d 100644 --- a/packages/mui-material/src/Select/SelectInput.js +++ b/packages/mui-material/src/Select/SelectInput.js @@ -504,8 +504,8 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) { aria-label={ariaLabel} aria-labelledby={[labelId, buttonId].filter(Boolean).join(' ') || undefined} aria-describedby={ariaDescribedby} - aria-required={required} - aria-invalid={error} + aria-required={required ? 'true' : undefined} + aria-invalid={error ? 'true' : undefined} onKeyDown={handleKeyDown} onMouseDown={disabled || readOnly ? null : handleMouseDown} onBlur={handleBlur}