-
-
Notifications
You must be signed in to change notification settings - Fork 485
fix: prevent aria props from being passed to wrapper div #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,6 +213,34 @@ describe('Select.Accessibility', () => { | |
| } | ||
| }); | ||
| }); | ||
|
|
||
| it('should pass aria and role attributes to Input component', async () => { | ||
| const { container } = render( | ||
| <Select | ||
| role="group" | ||
| aria-required="true" | ||
| options={[ | ||
| { | ||
| value: '123', | ||
| }, | ||
| { | ||
| value: '1234', | ||
| }, | ||
| { | ||
| value: '12345', | ||
| }, | ||
| ]} | ||
| />, | ||
| ); | ||
|
|
||
| const wrapper = container.querySelector('.rc-select'); | ||
| expect(wrapper).not.toHaveAttribute('role'); | ||
| expect(wrapper).not.toHaveAttribute('aria-required'); | ||
|
|
||
| const input = container.querySelector('input'); | ||
| expect(input).toHaveAttribute('role', 'group'); | ||
| expect(input).toHaveAttribute('aria-required', 'true'); | ||
| }); | ||
|
Comment on lines
+217
to
+243
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer
When to use listbox without combobox
Key ARIA requirements (summary)
References
🏁 Script executed: # Find and examine the Select component implementation around line 265
find . -type f -name "*.tsx" -o -name "*.ts" | head -20Repository: react-component/select Length of output: 716 🏁 Script executed: # Search for the Select component implementation to understand default role
rg -t tsx -t ts "role.*combobox|role.*group" --context 3Repository: react-component/select Length of output: 93 🏁 Script executed: # Look for the test file to understand the full context
find . -path "*/tests/*Accessibility*" -type fRepository: react-component/select Length of output: 96 🏁 Script executed: # Examine the Accessibility test file around line 265
cat -n ./tests/Accessibility.test.tsx | sed -n '260,280p'Repository: react-component/select Length of output: 936 🏁 Script executed: # Search for Select component implementation and default role
rg "role.*=.*combobox|role.*=.*group" --context 2Repository: react-component/select Length of output: 3100 🏁 Script executed: # Look for the main Select component file
find . -type f -name "*.tsx" -o -name "*.ts" | grep -i select | head -10Repository: react-component/select Length of output: 392 🏁 Script executed: # Search for role attribute assignments in the codebase
rg "role\s*=" --context 2 | head -50Repository: react-component/select Length of output: 2732 测试验证了属性传播机制,但使用的 ARIA role 不符合无障碍标准 新测试用例正确验证了属性在 Select 组件中的传播行为:包装器 div 不接收 但根据 WAI-ARIA 规范,Select 组件的 input 元素应使用 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| describe('Select Input attributes', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pickAttrsutility with the{ aria: true }option doesn't include theroleattribute. This meansrolewill not be added toariaKeysand will not be omitted from the wrapperdiv, which contradicts the goal of this PR and the associated tests. To ensureroleis also filtered out, you should includerole: truein thepickAttrsoptions.