You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an optional prop allowing user/consumer to set a heading level for the collapse button. We could use headingLevel?: h1 | h2 | h3 | h4 | h5 | h6, and then wrap the collapse-button-header in the <h_>.
Set an aria-controls attribute on each button, and the aria-controls would reference the id of the panel that the button controls.
Add an optional Collapse prop, panelsRole?: 'region' | 'none', by which consumers can optionally set role="region" on the panels.
These changes would have little impact on consumers implementation, but would improve accessibility by default, and also give consumers powerful opt-in functionality to set the heading level and role="region".
Please let me know if you find the proposed changes acceptable.
Reacted by Koyomi, Lucy Bullen, Katherine Beame and Jeremy Bell
Thank you for your proposal to enhance the accessibility of the Collapse component in Ant Design. Your suggestions to align with the W3C accessibility guidelines are valuable. Here's a summary of your proposed changes:
Heading Level Prop: Introduce an optional prop headingLevel to allow users to set a heading level for the collapse button, using options like h1 | h2 | h3 | h4 | h5 | h6. This would wrap the collapse-button-header in the corresponding <h_> tag.
Aria-Controls Attribute: Implement an aria-controls attribute on each button, which would reference the ID of the panel that the button controls, enhancing accessibility.
Panels Role Prop: Add an optional panelsRole prop, allowing consumers to set role="region" on the panels, with options 'region' | 'none'.
These enhancements aim to improve accessibility by default while providing consumers with the flexibility to opt-in for additional functionality. I will note your proposal for consideration by the team.
If you have any further questions or need additional assistance, feel free to ask.
🪧 Tips
For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.
Hello @John-Feola. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch (feature branch for the new feature, master for bugfix and other changes), fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!
@MadCcc
I am making changes in react-component/collapse to implement the proposed accessibility improvements. However, while working on the 2nd change to link the header and panel content by id, I found that in the collapse component there currently are no default IDs being generated and applied to the subcomponents.
In order to link the two elements without making consumers provide an ID to the Collapse component, I would like to include some default ID. I considered using the React.useId() hook, but that does not guarantee unique IDs when there are multiple react applications rendered at the same time. Another approach would be to use the uuid library to generate a default unique ID.
Would using uuid be acceptable or is there another suggested approach to generating default IDs that are unique across multiple react applications?
I have made changes in react-component/collapse to implement the proposed accessibility improvements: react-component/collapse#363
Note: I did not implement the panel role change because there is already some logic around setting the panel role to "tabpanel" when in accordion mode, and the panel role = "region" is optional for a11y purposes.
Activity
petercat-assistant commentedon Mar 18, 2025
Thank you for your proposal to enhance the accessibility of the Collapse component in Ant Design. Your suggestions to align with the W3C accessibility guidelines are valuable. Here's a summary of your proposed changes:
Heading Level Prop: Introduce an optional prop
headingLevelto allow users to set a heading level for the collapse button, using options likeh1 | h2 | h3 | h4 | h5 | h6. This would wrap the collapse-button-header in the corresponding<h_>tag.Aria-Controls Attribute: Implement an
aria-controlsattribute on each button, which would reference the ID of the panel that the button controls, enhancing accessibility.Panels Role Prop: Add an optional
panelsRoleprop, allowing consumers to setrole="region"on the panels, with options'region' | 'none'.These enhancements aim to improve accessibility by default while providing consumers with the flexibility to opt-in for additional functionality. I will note your proposal for consideration by the team.
If you have any further questions or need additional assistance, feel free to ask.
🪧 Tips
For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.MadCcc commentedon Mar 19, 2025
componentsprops for Collapse could be better, or it will be fixed by antd.github-actions commentedon Mar 19, 2025
Hello @John-Feola. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch (feature branch for the new feature, master for bugfix and other changes), fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!
你好 @John-Feola,我们完全同意你的提议/反馈,欢迎直接在此仓库 创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到正确的分支(新特性发到 feature 分支,其他发到 master 分支),务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待您的贡献。
mellis481 commentedon Mar 19, 2025
@MadCcc Can you provide some more information on what you are suggesting here please?
jon-cullison commentedon Mar 20, 2025
I will work on this issue.
jon-cullison commentedon Mar 25, 2025
@MadCcc
I am making changes in
react-component/collapseto implement the proposed accessibility improvements. However, while working on the 2nd change to link the header and panel content by id, I found that in the collapse component there currently are no default IDs being generated and applied to the subcomponents.In order to link the two elements without making consumers provide an ID to the Collapse component, I would like to include some default ID. I considered using the
React.useId()hook, but that does not guarantee unique IDs when there are multiple react applications rendered at the same time. Another approach would be to use theuuidlibrary to generate a default unique ID.Would using
uuidbe acceptable or is there another suggested approach to generating default IDs that are unique across multiple react applications?jon-cullison commentedon Apr 10, 2025
I have made changes in react-component/collapse to implement the proposed accessibility improvements: react-component/collapse#363
Note: I did not implement the panel role change because there is already some logic around setting the panel role to "tabpanel" when in accordion mode, and the panel role = "region" is optional for a11y purposes.