-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add selectAllLabel prop to TableView for customizing the aria-label of the select all checkbox #10530
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: main
Are you sure you want to change the base?
feat: add selectAllLabel prop to TableView for customizing the aria-label of the select all checkbox #10530
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 |
|---|---|---|
|
|
@@ -28,6 +28,14 @@ export interface TableSelectionCheckboxAria { | |
| checkboxProps: AriaCheckboxProps; | ||
| } | ||
|
|
||
| export interface AriaTableSelectAllCheckboxProps { | ||
| /** | ||
| * A custom aria-label for the select all checkbox. Overrides the default | ||
| * localized "Select All" label. | ||
| */ | ||
| 'aria-label'?: string; | ||
| } | ||
|
|
||
| export interface TableSelectAllCheckboxAria { | ||
| /** Props for the select all checkbox element. */ | ||
| checkboxProps: AriaCheckboxProps; | ||
|
|
@@ -60,13 +68,18 @@ export function useTableSelectionCheckbox<T>( | |
| * @param props - Props for the select all checkbox. | ||
| * @param state - State of the table, as returned by `useTableState`. | ||
| */ | ||
| export function useTableSelectAllCheckbox<T>(state: TableState<T>): TableSelectAllCheckboxAria { | ||
| export function useTableSelectAllCheckbox<T>( | ||
|
Member
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. This is already possible in RAC, so I don't think we need any props for the hooks
Author
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. yes, RAC already supports this via but v3's TableView renders that checkbox internally with no way for consumers to reach it β that's why I scoped this here. |
||
| state: TableState<T>, | ||
| props: AriaTableSelectAllCheckboxProps = {} | ||
| ): TableSelectAllCheckboxAria { | ||
| let {isEmpty, isSelectAll, selectionMode} = state.selectionManager; | ||
| const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/table'); | ||
|
|
||
| return { | ||
| checkboxProps: { | ||
| 'aria-label': stringFormatter.format(selectionMode === 'single' ? 'select' : 'selectAll'), | ||
| 'aria-label': | ||
| props['aria-label'] ?? | ||
| stringFormatter.format(selectionMode === 'single' ? 'select' : 'selectAll'), | ||
| isSelected: isSelectAll, | ||
| isDisabled: | ||
| selectionMode !== 'multiple' || | ||
|
|
||
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.
I don't think we'll introduce this to TableView in v3, only in S2 and it's already possible in RAC
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.
we haven't migrated our project to S2 yet, and this came out of an accessibility audit that requires us to fix it in the near future β is there any chance you'd reconsider adding it to v3 too?