-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: better a11y #509
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
feat: better a11y #509
Changes from all commits
dece1b0
b7388d4
2a4f330
625204d
e081d1b
3c7e909
095b9cb
e505c88
fe2e017
403dd52
e1082bf
ac227c5
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||
| "declaration": true, | ||||||
| "skipLibCheck": true, | ||||||
| "esModuleInterop": true, | ||||||
| "types": ["@testing-library/jest-dom"], | ||||||
|
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. By adding the
Suggested change
Rules ReferencesFootnotes
|
||||||
| "paths": { | ||||||
| "@/*": [ | ||||||
| "src/*" | ||||||
|
|
||||||
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.
修复 aria-describedby 属性覆盖问题。
React.cloneElement(child, ariaProps)会直接覆盖子元素已有的aria-describedby属性,破坏子元素自身的无障碍关联关系。根据 WAI-ARIA 规范,应使用空格分隔的 ID 列表合并多个描述源。应用此 diff 以正确合并 aria-describedby:
const getChildren: TriggerProps['children'] = ({ open }) => { const child = React.Children.only(children); + const existingDescribedBy = child.props['aria-describedby']; + const tooltipDescribedBy = overlay && open ? mergedId : undefined; + const mergedDescribedBy = + tooltipDescribedBy && existingDescribedBy + ? `${existingDescribedBy} ${tooltipDescribedBy}` + : tooltipDescribedBy || existingDescribedBy; const ariaProps: React.AriaAttributes = { - 'aria-describedby': overlay && open ? mergedId : undefined, + 'aria-describedby': mergedDescribedBy, }; return React.cloneElement(child, ariaProps); };📝 Committable suggestion
🤖 Prompt for AI Agents