diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 96e80b336..056c714c7 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -398,7 +398,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r
{ diff --git a/tests/Accessibility.test.tsx b/tests/Accessibility.test.tsx index 7b2c83bf8..1e4df9e90 100644 --- a/tests/Accessibility.test.tsx +++ b/tests/Accessibility.test.tsx @@ -132,4 +132,82 @@ describe('Select.Accessibility', () => { }); expectOpen(container); }); + + // https://github.com/ant-design/ant-design/issues/53713 + describe('Select ARIA attributes', () => { + it('should have correct aria and role attributes in virtual true', () => { + render( + , + ); + + const dropdown = document.querySelector('#virtual-select_list'); + expect(dropdown).toHaveAttribute('role', 'listbox'); + + const options = dropdown.querySelectorAll('.rc-select-item-option'); + options.forEach((option) => { + expect(option).toHaveAttribute('role', 'option'); + const ariaSelected = option.getAttribute('aria-selected'); + if (ariaSelected !== null) { + expect(['true', 'false']).toContain(ariaSelected); + } + }); + }); + }); }); diff --git a/tests/__snapshots__/OptionList.test.tsx.snap b/tests/__snapshots__/OptionList.test.tsx.snap index c344c0c5c..b3f70414d 100644 --- a/tests/__snapshots__/OptionList.test.tsx.snap +++ b/tests/__snapshots__/OptionList.test.tsx.snap @@ -45,7 +45,6 @@ exports[`OptionList renders correctly virtual 1`] = `
@@ -73,7 +72,6 @@ exports[`OptionList renders correctly virtual 1`] = ` group2
diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 041f8d551..37e74e55a 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -42,7 +42,6 @@ exports[`Select.Basic does not filter when filterOption value is false 1`] = ` style="display: flex; flex-direction: column;" >
@@ -63,7 +62,6 @@ exports[`Select.Basic does not filter when filterOption value is false 1`] = `
@@ -418,7 +416,6 @@ exports[`Select.Basic render should support fieldName 1`] = ` groupLabel
@@ -465,7 +462,6 @@ exports[`Select.Basic render should support fieldName 2`] = ` groupLabel
@@ -512,7 +508,6 @@ exports[`Select.Basic render should support fieldName 3`] = ` groupLabel
@@ -580,7 +575,6 @@ exports[`Select.Basic should contain falsy children 1`] = ` style="display: flex; flex-direction: column;" >
@@ -603,7 +597,6 @@ exports[`Select.Basic should contain falsy children 1`] = `
@@ -679,7 +672,6 @@ exports[`Select.Basic should render custom dropdown correctly 1`] = ` style="display: flex; flex-direction: column;" >
@@ -700,7 +692,6 @@ exports[`Select.Basic should render custom dropdown correctly 1`] = `
diff --git a/tests/__snapshots__/Tags.test.tsx.snap b/tests/__snapshots__/Tags.test.tsx.snap index 477783d55..49b7ee55f 100644 --- a/tests/__snapshots__/Tags.test.tsx.snap +++ b/tests/__snapshots__/Tags.test.tsx.snap @@ -150,7 +150,6 @@ exports[`Select.Tags OptGroup renders correctly 1`] = ` Manager
@@ -179,7 +178,6 @@ exports[`Select.Tags OptGroup renders correctly 1`] = ` Engineer
@@ -200,7 +198,6 @@ exports[`Select.Tags OptGroup renders correctly 1`] = `