From 72c822bc06fa4f9d7d70a06b3d50dd950aff8703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=87=E8=A7=81=E5=90=8C=E5=AD=A6?= <1875694521@qq.com> Date: Sun, 6 Jul 2025 23:58:54 +0800 Subject: [PATCH 1/2] fix: role and aria-selected a11y error (#1158) --- src/OptionList.tsx | 2 +- tests/Accessibility.test.tsx | 78 ++++++++++++++++++++ tests/__snapshots__/OptionList.test.tsx.snap | 2 - tests/__snapshots__/Select.test.tsx.snap | 9 --- tests/__snapshots__/Tags.test.tsx.snap | 3 - 5 files changed, 79 insertions(+), 15 deletions(-) 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`] = `
From 48e24574fdf6a7b68589631e32d69d8dc629c974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 17 Jul 2025 11:57:32 +0800 Subject: [PATCH 2/2] chore: bump version to 1.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd77b65ed..cb52b5a70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rc-component/select", - "version": "1.1.2", + "version": "1.1.3", "description": "React Select", "engines": { "node": ">=8.x"