fix(accessibility): Enable tabbing on sort header of table chart (#26326)

This commit is contained in:
arun 2023-12-23 11:58:41 +05:30 committed by GitHub
parent 3391e29093
commit b6d433de32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -71,6 +71,12 @@ interface TableSize {
height: number;
}
const ACTION_KEYS = {
enter: 'Enter',
spacebar: 'Spacebar',
space: ' ',
};
/**
* Return sortType based on data type
*/
@ -591,6 +597,13 @@ export default function TableChart<D extends DataRecord = DataRecord>(
...sharedStyle,
...style,
}}
tabIndex={0}
onKeyDown={(e: React.KeyboardEvent<HTMLElement>) => {
// programatically sort column on keypress
if (Object.values(ACTION_KEYS).includes(e.key)) {
col.toggleSortBy();
}
}}
onClick={onClick}
data-column-name={col.id}
{...(allowRearrangeColumns && {