-
Notifications
You must be signed in to change notification settings - Fork 137
feat: accessibility improvements #363
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
3c61fff
9f789a2
f8676e7
089346c
af2984e
55bc778
5360802
dbad27a
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 |
---|---|---|
|
@@ -25,6 +25,8 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop | |
openMotion, | ||
destroyOnHidden, | ||
children, | ||
headingLevel, | ||
id, | ||
...resetProps | ||
} = props; | ||
|
||
|
@@ -87,17 +89,23 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop | |
|
||
// ======================== Render ======================== | ||
return ( | ||
<div {...resetProps} ref={ref} className={collapsePanelClassNames}> | ||
<div {...headerProps}> | ||
{showArrow && iconNode} | ||
<span | ||
className={classNames(`${prefixCls}-title`, customizeClassNames?.title)} | ||
style={styles?.title} | ||
{...(collapsible === 'header' ? collapsibleProps : {})} | ||
> | ||
{header} | ||
</span> | ||
{ifExtraExist && <div className={`${prefixCls}-extra`}>{extra}</div>} | ||
<div {...resetProps} ref={ref} className={collapsePanelClassNames} id={id}> | ||
<div | ||
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. Replace with h3 directly |
||
className={`${prefixCls}-header-wrapper`} | ||
role={headingLevel ? 'heading' : undefined} | ||
aria-level={headingLevel} | ||
> | ||
<div {...headerProps} id={`${id}__header`} aria-controls={`${id}__content`}> | ||
{showArrow && iconNode} | ||
<span | ||
className={classNames(`${prefixCls}-title`, customizeClassNames?.title)} | ||
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. replace this with HeadingElement instead of span directly. It's no need to have additional HeaderWrapper. 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. I can change HeaderWrapper, but replacing the span would not satisfy the a11y standards for collapse / accordion components. The heading element should wrap the header button, which is where HeaderWrapper is in this PR. Would you prefer it to be a div that is always present around the button, instead of conditionally rendered, but it only would have the heading role and aria-level when the prop is defined? 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. OK. So you can add on the 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. Update - the rc-collapse-header element gets the button role, so to satisfy the a11y standards for the header, I changed to a div element that always wraps rc-collapse-header and will conditionally have the heading role and aria-level props set. 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. @zombieJ Can you please review my latest changes with my previous comment in mind? |
||
style={styles?.title} | ||
{...(collapsible === 'header' ? collapsibleProps : {})} | ||
> | ||
{header} | ||
</span> | ||
{ifExtraExist && <div className={`${prefixCls}-extra`}>{extra}</div>} | ||
</div> | ||
</div> | ||
<CSSMotion | ||
visible={isActive} | ||
|
@@ -110,6 +118,8 @@ const CollapsePanel = React.forwardRef<HTMLDivElement, CollapsePanelProps>((prop | |
return ( | ||
<PanelContent | ||
ref={motionRef} | ||
id={`${id}__content`} | ||
aria-labelledby={`${id}__header`} | ||
prefixCls={prefixCls} | ||
className={motionClassName} | ||
classNames={customizeClassNames} | ||
|
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.
Currently we can simply use h3 instead of configuable headingLevel