Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3bc6f78
poking around to make Rows process nested rows
LFDanLu May 31, 2023
0bf43fd
cleanup
LFDanLu May 31, 2023
4609379
progress
LFDanLu Jun 1, 2023
22dde54
got nested rows rendering
LFDanLu Jun 2, 2023
9fb0a5f
fixing naming and adding way to track rows that have nested rows
LFDanLu Jun 2, 2023
d57f877
fixing expandable row detection and debugging weird TableLayout issue
LFDanLu Jun 2, 2023
529125e
Merge branch 'main' of github.com:adobe/react-spectrum into expandabl…
LFDanLu Jun 5, 2023
7c26625
renaming from treeble to TreeGrid
LFDanLu Jun 5, 2023
4db5b4c
fix cell values and weird crash with dynamic treeble with subset of k…
LFDanLu Jun 5, 2023
092b43c
update left/right keyboard navigation logic
LFDanLu Jun 6, 2023
c630325
updating up/down keyboard navigation logic
LFDanLu Jun 6, 2023
29cd760
fixing typeahead and using this.getChildNodes whereever possible
LFDanLu Jun 6, 2023
2af16aa
cleanup and fix getText
LFDanLu Jun 6, 2023
c44b194
fixing index and column assignment to node
LFDanLu Jun 6, 2023
b4a9cf1
debugging persisted keys
LFDanLu Jun 6, 2023
c8aa238
adding basic story to check controlled expanded keys
LFDanLu Jun 7, 2023
c9ca507
musings when trying to fix persisted key case
LFDanLu Jun 7, 2023
b5c62d8
enforcing user places cells before nested rows
LFDanLu Jun 8, 2023
a6f090e
making GridNode index track position with respect to parent and addin…
LFDanLu Jun 8, 2023
56d31cb
fixing persisted keys by adding index for headerrows and columns
LFDanLu Jun 8, 2023
6671f88
create Table wrapper element to conditionally render Table or TreeGri…
LFDanLu Jun 8, 2023
1a00526
get rid of extra story
LFDanLu Jun 8, 2023
fdcf68b
update keyboard delegate to use node.indexOfType
LFDanLu Jun 8, 2023
5ccc400
adding tree grid aria
LFDanLu Jun 9, 2023
e423431
fix crash on collapse
LFDanLu Jun 9, 2023
6ef96de
fixes from screen reader testing
LFDanLu Jun 12, 2023
bb30a78
setting up tests, debugging why they dont run
LFDanLu Jun 12, 2023
7d5a3a6
add feature flag getter for tests for now
LFDanLu Jun 13, 2023
73ec246
fixing row border styling and adding more tests
LFDanLu Jun 14, 2023
c0f5ca8
Merge branch 'main' of github.com:adobe/react-spectrum into expandabl…
LFDanLu Jun 14, 2023
6535a2c
TableView expandable rows: rendering + interactions (#4663)
reidbarber Jun 20, 2023
8c6aafe
Merge branch 'main' of github.com:adobe/react-spectrum into expandabl…
LFDanLu Jun 23, 2023
cddc437
fix shared context for base tableview and treegrid tableview
LFDanLu Jun 23, 2023
4ee99c5
fixing lint for build
LFDanLu Jun 23, 2023
191f96a
adding more stories
LFDanLu Jun 23, 2023
e73aca3
adding more row selection test
LFDanLu Jun 24, 2023
98f34eb
make NVDA/Talkback not announce the chevron label when the cell is fo…
LFDanLu Jun 26, 2023
c3cf0ae
add chevron rotation transition and increase hit target
LFDanLu Jun 26, 2023
ca0ed13
add chromatic stories
reidbarber Jun 27, 2023
465c471
adding tests for loading state, onAction, and highlight selection
LFDanLu Jun 29, 2023
b509f40
adding persisted key and remaining keyboard nav tests
LFDanLu Jun 30, 2023
4b84adb
add expand/collapse tests
LFDanLu Jun 30, 2023
bf8adff
(WIP) Simplify TreeGridCollection by building the keymap inside state…
LFDanLu Jun 30, 2023
dfcdea1
Refactoring TableView wrapper strategy
LFDanLu Jun 30, 2023
8c20b77
renaming tableview files
LFDanLu Jun 30, 2023
1ec0deb
getting rid of extraneous shouldShowCheckbox
LFDanLu Jun 30, 2023
3d1eecc
Merge branch 'main' of github.com:adobe/react-spectrum into expandabl…
LFDanLu Jun 30, 2023
0f98137
fixing tests for react-17
LFDanLu Jul 1, 2023
6ab1d16
cleaning up todos
LFDanLu Jul 11, 2023
9537eab
Merge branch 'main' into expandable_rows_collection_update
LFDanLu Jul 11, 2023
b38acc3
adding alpha to types
LFDanLu Jul 11, 2023
bb2bae2
Add message for feature flag pointing to docs
LFDanLu Jul 11, 2023
ced41eb
Remove zoom transition effect from TableView (#4771)
LFDanLu Jul 17, 2023
7fc7fef
Adding UNSTABLE to expandable rows state hook and prop
LFDanLu Jul 18, 2023
dfae99b
addressing review comments
LFDanLu Jul 18, 2023
d2324b8
moving expand/collapse chevron label to intl files
LFDanLu Jul 18, 2023
db3348f
Merge branch 'main' of github.com:adobe/react-spectrum into expandabl…
LFDanLu Jul 18, 2023
c517cec
addressing review comments (prop rename and stuff)
LFDanLu Jul 20, 2023
777de01
hide expandable table props from spectrum docs
LFDanLu Jul 20, 2023
c9e9d76
removing column node assigment to treegrid node cell
LFDanLu Jul 20, 2023
de56a4f
expanding type and fixing tests to get rid of .onlys
LFDanLu Jul 20, 2023
02515a9
fix tests in 17
LFDanLu Jul 20, 2023
5cfc080
Merge branch 'main' into expandable_rows_collection_update
LFDanLu Jul 21, 2023
274ed6c
Fix click focus and transform overlap for expandable row chevron (#4808)
LFDanLu Jul 21, 2023
d0cf261
Merge branch 'main' into expandable_rows_collection_update
LFDanLu Jul 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions packages/@adobe/spectrum-css-temp/components/table/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,27 +219,29 @@ svg.spectrum-Table-sortedIcon {
}
}

.spectrum-Table-cell {
box-sizing: border-box;
font-size: var(--spectrum-table-cell-text-size);
font-weight: var(--spectrum-table-cell-text-font-weight);
/* need to subtract 1px here because 14px * 1.5 + 14px + 14px = 49px, and we want 48px */
line-height: calc(calc(var(--spectrum-table-cell-text-size) * var(--spectrum-table-cell-text-line-height)) - 1px);
padding: var(--spectrum-table-cell-regular-padding-y) var(--spectrum-table-cell-padding-x);
.spectrum-Table--regular {
--spectrum-table-cell-padding-y: var(--spectrum-table-cell-regular-padding-y);
}
.spectrum-Table--regular {}

.spectrum-Table--compact .spectrum-Table-cell {
padding-top: var(--spectrum-table-cell-compact-padding-y);
padding-bottom: var(--spectrum-table-cell-compact-padding-y);
--spectrum-table-cell-padding-y: var(--spectrum-table-cell-compact-padding-y);
}

.spectrum-Table--spacious .spectrum-Table-cell {
padding-top: var(--spectrum-table-cell-spacious-padding-y);
padding-bottom: var(--spectrum-table-cell-spacious-padding-y);
--spectrum-table-cell-padding-y: var(--spectrum-table-cell-spacious-padding-y);
}

.spectrum-Table-cell {
box-sizing: border-box;
font-size: var(--spectrum-table-cell-text-size);
font-weight: var(--spectrum-table-cell-text-font-weight);
/* need to subtract 1px here because 14px * 1.5 + 14px + 14px = 49px, and we want 48px */
line-height: calc(calc(var(--spectrum-table-cell-text-size) * var(--spectrum-table-cell-text-line-height)) - 1px);
padding: var(--spectrum-table-cell-padding-y) var(--spectrum-table-cell-padding-x);
}

.spectrum-Table-cellContents {
grid-area: contents;
flex: 1 1 0%;
/* To ensure the flex child only takes up available width, see https://makandracards.com/makandra/66994-css-flex-and-min-width */
min-width: 0px;
Expand All @@ -254,6 +256,26 @@ svg.spectrum-Table-sortedIcon {
margin: -4px;
}

.spectrum-Table-expandButton {
grid-area: expand-button;
height: var(--spectrum-global-dimension-size-400);
margin: calc(var(--spectrum-table-cell-padding-y) * -1) 0;
display: flex;
flex-wrap: wrap;
align-content: center;
justify-content: center;
outline: none;
transition: transform ease var(--spectrum-global-animation-duration-100);
&.is-open {
[dir='ltr'] & {
transform: rotate(90deg);
}
[dir='rtl'] & {
transform: rotate(-90deg);
}
}
}

.spectrum-Table-cell--hideHeader {
padding: 0;
justify-content: center;
Expand Down
6 changes: 3 additions & 3 deletions packages/@react-aria/grid/src/useGridRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
* governing permissions and limitations under the License.
*/

import {DOMAttributes, FocusableElement, Node} from '@react-types/shared';
import {GridCollection} from '@react-types/grid';
import {DOMAttributes, FocusableElement} from '@react-types/shared';
import {GridCollection, GridNode} from '@react-types/grid';
import {gridMap} from './utils';
import {GridState} from '@react-stately/grid';
import {RefObject} from 'react';
import {SelectableItemStates, useSelectableItem} from '@react-aria/selection';

export interface GridRowProps<T> {
/** An object representing the grid row. Contains all the relevant information that makes up the grid row. */
node: Node<T>,
node: GridNode<T>,
/** Whether the grid row is contained in a virtual scroller. */
isVirtualized?: boolean,
/** Whether selection should occur on press up instead of press down. */
Expand Down
8 changes: 6 additions & 2 deletions packages/@react-aria/table/src/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {mergeProps, useDescription, useId, useUpdateEffect} from '@react-aria/ut
import {Node} from '@react-types/shared';
import {RefObject, useMemo} from 'react';
import {TableKeyboardDelegate} from './TableKeyboardDelegate';
import {TableState} from '@react-stately/table';
import {TableState, TreeGridState} from '@react-stately/table';
import {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';

export interface AriaTableProps<T> extends GridProps {
Expand All @@ -36,7 +36,7 @@ export interface AriaTableProps<T> extends GridProps {
* @param state - State for the table, as returned by `useTableState`.
* @param ref - The ref attached to the table element.
*/
export function useTable<T>(props: AriaTableProps<T>, state: TableState<T>, ref: RefObject<HTMLElement>): GridAria {
export function useTable<T>(props: AriaTableProps<T>, state: TableState<T> | TreeGridState<T>, ref: RefObject<HTMLElement>): GridAria {
let {
keyboardDelegate,
isVirtualized,
Expand Down Expand Up @@ -70,6 +70,10 @@ export function useTable<T>(props: AriaTableProps<T>, state: TableState<T>, ref:
gridProps['aria-rowcount'] = state.collection.size + state.collection.headerRows.length;
}

if ('expandedKeys' in state) {
gridProps.role = 'treegrid';
}
Comment on lines +73 to +75
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opted to put tree grid specific aria attributes in table hooks level, not grid hook level. If it turns out that we will have other components that only call the grid hooks and need tree grid aria attributes, then we can refactor.


let {column, direction: sortDirection} = state.sortDescriptor || {};
let stringFormatter = useLocalizedStringFormatter(intlMessages);
let sortDescription = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/table/src/useTableHeaderRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function useTableHeaderRow<T>(props: GridRowProps<T>, state: TableState<T
role: 'row'
};

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

Expand Down
58 changes: 53 additions & 5 deletions packages/@react-aria/table/src/useTableRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,71 @@
*/

import {FocusableElement} from '@react-types/shared';
import {getLastItem} from '@react-stately/collections';
import {getRowLabelledBy} from './utils';
import type {GridNode} from '@react-types/grid';
import {GridRowAria, GridRowProps, useGridRow} from '@react-aria/grid';
import {RefObject} from 'react';
import {HTMLAttributes, RefObject} from 'react';
import {mergeProps} from '@react-aria/utils';
import {TableCollection} from '@react-types/table';
import {TableState} from '@react-stately/table';
import {TableState, TreeGridState} from '@react-stately/table';
import {useLocale} from '@react-aria/i18n';

const EXPANSION_KEYS = {
expand: {
ltr: 'ArrowRight',
rtl: 'ArrowLeft'
},
'collapse': {
ltr: 'ArrowLeft',
rtl: 'ArrowRight'
}
};

/**
* Provides the behavior and accessibility implementation for a row in a table.
* @param props - Props for the row.
* @param state - State of the table, as returned by `useTableState`.
*/
export function useTableRow<T>(props: GridRowProps<T>, state: TableState<T>, ref: RefObject<FocusableElement>): GridRowAria {
let {node} = props;
export function useTableRow<T>(props: GridRowProps<T>, state: TableState<T> | TreeGridState<T>, ref: RefObject<FocusableElement>): GridRowAria {
let {node, isVirtualized} = props;
let {rowProps, ...states} = useGridRow<T, TableCollection<T>, TableState<T>>(props, state, ref);
let {direction} = useLocale();

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

let treeGridRowProps: HTMLAttributes<HTMLElement> = {};
if ('expandedKeys' in state) {
let treeNode = state.keyMap.get(node.key);
if (treeNode != null) {
let hasChildRows = treeNode.props?.UNSTABLE_childItems || treeNode.props?.children?.length > state.userColumnCount;
treeGridRowProps = {
onKeyDown: (e) => {
if ((e.key === EXPANSION_KEYS['expand'][direction]) && state.selectionManager.focusedKey === treeNode.key && hasChildRows && state.expandedKeys !== 'all' && !state.expandedKeys.has(treeNode.key)) {
state.toggleKey(treeNode.key);
e.stopPropagation();
} else if ((e.key === EXPANSION_KEYS['collapse'][direction]) && state.selectionManager.focusedKey === treeNode.key && hasChildRows && (state.expandedKeys === 'all' || state.expandedKeys.has(treeNode.key))) {
state.toggleKey(treeNode.key);
e.stopPropagation();
}
},
'aria-expanded': hasChildRows ? state.expandedKeys === 'all' || state.expandedKeys.has(node.key) : undefined,
'aria-level': treeNode.level,
'aria-posinset': treeNode.indexOfType + 1,
'aria-setsize': treeNode.level > 1 ?
(getLastItem(state.keyMap.get(treeNode?.parentKey).childNodes) as GridNode<T>).indexOfType + 1 :
(getLastItem(state.keyMap.get(state.collection.body.key).childNodes) as GridNode<T>).indexOfType + 1
};
}
}

return {
rowProps: {
...rowProps,
...mergeProps(rowProps, treeGridRowProps),
'aria-labelledby': getRowLabelledBy(state, node.key)
},
...states
Expand Down
Loading