Skip to content

Commit d745bd4

Browse files
authored
Adding feature flag check for expandable table rows in aria hooks (#4865)
* Adding feature flag check for expandable table rows in aria hooks * lint
1 parent 5f31e24 commit d745bd4

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

packages/@react-aria/table/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@react-aria/utils": "^3.18.0",
3232
"@react-aria/visually-hidden": "^3.8.2",
3333
"@react-stately/collections": "^3.9.0",
34+
"@react-stately/flags": "3.0.0-alpha.0",
3435
"@react-stately/table": "^3.10.0",
3536
"@react-stately/virtualizer": "^3.6.0",
3637
"@react-types/checkbox": "^3.4.4",

packages/@react-aria/table/src/useTable.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {mergeProps, useDescription, useId, useUpdateEffect} from '@react-aria/ut
2020
import {Node} from '@react-types/shared';
2121
import {RefObject, useMemo} from 'react';
2222
import {TableKeyboardDelegate} from './TableKeyboardDelegate';
23+
import {tableNestedRows} from '@react-stately/flags';
2324
import {TableState, TreeGridState} from '@react-stately/table';
2425
import {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
2526

@@ -70,7 +71,7 @@ export function useTable<T>(props: AriaTableProps<T>, state: TableState<T> | Tre
7071
gridProps['aria-rowcount'] = state.collection.size + state.collection.headerRows.length;
7172
}
7273

73-
if ('expandedKeys' in state) {
74+
if (tableNestedRows() && 'expandedKeys' in state) {
7475
gridProps.role = 'treegrid';
7576
}
7677

packages/@react-aria/table/src/useTableHeaderRow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import {DOMAttributes} from '@react-types/shared';
1414
import {GridRowProps} from '@react-aria/grid';
1515
import {RefObject} from 'react';
16+
import {tableNestedRows} from '@react-stately/flags';
1617
import {TableState} from '@react-stately/table';
1718

1819
export interface TableHeaderRowAria {
@@ -32,7 +33,7 @@ export function useTableHeaderRow<T>(props: GridRowProps<T>, state: TableState<T
3233
role: 'row'
3334
};
3435

35-
if (isVirtualized && !('expandedKeys' in state)) {
36+
if (isVirtualized && !(tableNestedRows() && 'expandedKeys' in state)) {
3637
rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based
3738
}
3839

packages/@react-aria/table/src/useTableRow.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {GridRowAria, GridRowProps, useGridRow} from '@react-aria/grid';
1818
import {HTMLAttributes, RefObject} from 'react';
1919
import {mergeProps} from '@react-aria/utils';
2020
import {TableCollection} from '@react-types/table';
21+
import {tableNestedRows} from '@react-stately/flags';
2122
import {TableState, TreeGridState} from '@react-stately/table';
2223
import {useLocale} from '@react-aria/i18n';
2324

@@ -42,14 +43,14 @@ export function useTableRow<T>(props: GridRowProps<T>, state: TableState<T> | Tr
4243
let {rowProps, ...states} = useGridRow<T, TableCollection<T>, TableState<T>>(props, state, ref);
4344
let {direction} = useLocale();
4445

45-
if (isVirtualized && !('expandedKeys' in state)) {
46+
if (isVirtualized && !(tableNestedRows() && 'expandedKeys' in state)) {
4647
rowProps['aria-rowindex'] = node.index + 1 + state.collection.headerRows.length; // aria-rowindex is 1 based
4748
} else {
4849
delete rowProps['aria-rowindex'];
4950
}
5051

5152
let treeGridRowProps: HTMLAttributes<HTMLElement> = {};
52-
if ('expandedKeys' in state) {
53+
if (tableNestedRows() && 'expandedKeys' in state) {
5354
let treeNode = state.keyMap.get(node.key);
5455
if (treeNode != null) {
5556
let hasChildRows = treeNode.props?.UNSTABLE_childItems || treeNode.props?.children?.length > state.userColumnCount;

0 commit comments

Comments
 (0)