-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Table Column Resize via screen readers #3295
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
Changes from all commits
7f5bcaf
fd0df6a
7246140
964bb5f
01b6f9e
5f4a54d
75fe702
7a521a3
5b94679
2d942c9
c58e258
218689e
9d1d5a4
e6594be
11951b8
b9b2043
eb4b860
48b09cb
e6a531a
4825f50
fdf1d1e
6623a3c
b48aa5b
ed01e29
fe73dee
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 |
---|---|---|
|
@@ -27,7 +27,9 @@ export interface AriaTableColumnHeaderProps { | |
/** An object representing the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader). Contains all the relevant information that makes up the column header. */ | ||
node: GridNode<unknown>, | ||
/** Whether the [column header](https://www.w3.org/TR/wai-aria-1.1/#columnheader) is contained in a virtual scroller. */ | ||
isVirtualized?: boolean | ||
isVirtualized?: boolean, | ||
/** Whether the column has a menu in the header, this changes interactions with the header. */ | ||
hasMenu?: boolean | ||
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. Should this be less specific to menus? Should it be more like an override to disable the default sorting behavior? 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. Maybe, what are the use cases other than a menu where we'd want to disable the default sorting behavior? 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. Not sure, but I mainly wondered if menus were too spectrum-specific? 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. maybe, it was the ask for a future feature, custom menu options on columns. so that's where the name came from. I'm fine changing it though to |
||
} | ||
|
||
export interface TableColumnHeaderAria { | ||
|
@@ -43,25 +45,27 @@ export interface TableColumnHeaderAria { | |
*/ | ||
export function useTableColumnHeader<T>(props: AriaTableColumnHeaderProps, state: TableState<T>, ref: RefObject<FocusableElement>): TableColumnHeaderAria { | ||
let {node} = props; | ||
let allowsResizing = node.props.allowsResizing; | ||
let allowsSorting = node.props.allowsSorting; | ||
// the selection cell column header needs to focus the checkbox within it but the other columns should focus the cell so that focus doesn't land on the resizer | ||
let {gridCellProps} = useGridCell({...props, focusMode: node.props.isSelectionCell || node.props.allowsResizing || node.props.allowsSorting ? 'child' : 'cell'}, state, ref); | ||
let {gridCellProps} = useGridCell({...props, focusMode: node.props.isSelectionCell || props.hasMenu || node.props.allowsSorting ? 'child' : 'cell'}, state, ref); | ||
|
||
let isSelectionCellDisabled = node.props.isSelectionCell && state.selectionManager.selectionMode === 'single'; | ||
|
||
let {pressProps} = usePress({ | ||
// Disabled for allowsResizing because if resizing is allowed, a menu trigger is added to the column header. | ||
isDisabled: (!(allowsSorting || allowsResizing)) || isSelectionCellDisabled, | ||
isDisabled: !allowsSorting || isSelectionCellDisabled, | ||
onPress() { | ||
!allowsResizing && state.sort(node.key); | ||
state.sort(node.key); | ||
}, | ||
ref | ||
}); | ||
|
||
// Needed to pick up the focusable context, enabling things like Tooltips for example | ||
let {focusableProps} = useFocusable({}, ref); | ||
|
||
if (props.hasMenu) { | ||
pressProps = {}; | ||
} | ||
|
||
let ariaSort: DOMAttributes['aria-sort'] = null; | ||
let isSortedColumn = state.sortDescriptor?.column === node.key; | ||
let sortDirection = state.sortDescriptor?.direction; | ||
|
@@ -84,7 +88,9 @@ export function useTableColumnHeader<T>(props: AriaTableColumnHeaderProps, state | |
|
||
return { | ||
columnHeaderProps: { | ||
...mergeProps(gridCellProps, pressProps, focusableProps, descriptionProps), | ||
...mergeProps(gridCellProps, pressProps, focusableProps, descriptionProps, { | ||
onPointerDown: (e) => console.log(e.target.outerHTML) | ||
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. Assume this was not meant to go in. |
||
}), | ||
role: 'columnheader', | ||
id: getColumnHeaderId(state, node.key), | ||
'aria-colspan': node.colspan && node.colspan > 1 ? node.colspan : null, | ||
|
Uh oh!
There was an error while loading. Please reload this page.