-
Notifications
You must be signed in to change notification settings - Fork 322
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(Modal): allow accepting custom arias, allow passing ReactNode to ModalHeader's title #2702
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 |
---|---|---|
|
@@ -9,7 +9,12 @@ interface WithoutDescription { | |
interface WithDescription { | ||
/** | ||
* Descriptive text or content below the title. | ||
* When supplied, would also add an aria-describedby attribute to the modal dialog element. | ||
* - If you pass a **string**, this will automatically set an internally generated `aria-describedby` on the parent Modal. | ||
* - If you pass a **ReactNode** (e.g., a complex component), we recommend assigning an **`id`** to that component (or a nested element), | ||
* and then pass that same ID in `aria-describedby` to the **Modal** (overriding the internal ID). | ||
* | ||
* This ensures that assistive technologies know which element is the modal's descriptive content. | ||
* @see [WAI-ARIA Authoring Practices for Dialog (Modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/#wai-ariaroles,states,andproperties) | ||
*/ | ||
description: string | React.ReactNode; | ||
/** | ||
|
@@ -26,8 +31,16 @@ interface WithDescription { | |
export type ModalHeaderProps = { | ||
/** | ||
* Main heading text of the modal. | ||
* When supplied, would also add an aria-labelledby attribute to the modal dialog element. | ||
* | ||
* - If you pass a **string**, `ModalHeader` will generate an internal ID and communicate it to the parent `Modal` | ||
* so that `aria-labelledby` is set automatically (unless `Modal` receives `aria-labelledby` prop). | ||
* - If you pass a **ReactNode** (such as a custom component), **you must**: | ||
* 1. Assign an **`id`** to that element (or a nested element), and | ||
* 2. Pass that **same `id`** as the `aria-labelledby` prop to the `Modal`. | ||
* | ||
* This ensures that assistive technologies know which element is the modal's title. | ||
* @see [WAI-ARIA Authoring Practices for Dialog (Modal)](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/#wai-ariaroles,states,andproperties) | ||
*/ | ||
title: string; | ||
title: string | React.ReactNode; | ||
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. ElementContent? Or we don't want it because it's less descriptive? 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. Also, can it be an array? 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. It's a good point, let's see if a request arises, and we can add it later. I believe most of the use cases would be wrapped under a single I generally don't like the |
||
} & (WithDescription | WithoutDescription) & | ||
VibeComponentProps; |
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.
Nice, very detailed explanation