You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -259,19 +259,18 @@ Now that we've covered the table header, let's move on to the body. We'll use
259
259
the <TypeLinklinks={docs.links}type={docs.exports.useTableRow} /> hook to render each row in the table.
260
260
Table rows can be focused and navigated to using the keyboard via the arrow keys. In addition, table rows
261
261
can optionally support selection via mouse, touch, or keyboard. Clicking, tapping, or pressing the <kbd>Space</kbd>
262
-
key anywhere in the row selects it. Row actions are also supported via the provided `onAction` prop. See[below](#row-and-cell-actions) for details.
262
+
key anywhere in the row selects it. Row actions are also supported, see[below](#row-and-cell-actions) for details.
263
263
264
264
We'll use the <TypeLinklinks={selectionDocs.links}type={selectionDocs.exports.SelectionManager} /> object exposed
265
265
by the `state` to determine if a row is selected, and render a pink background if so. We'll also use the <TypeLinklinks={focusDocs.links}type={focusDocs.exports.useFocusRing} />
266
266
hook to render a focus ring when the user navigates to the row with the keyboard.
267
267
268
268
```tsx example export=true render=false
269
-
function TableRow({item, children, state, onAction}) {
269
+
function TableRow({item, children, state}) {
270
270
let ref =useRef();
271
271
let isSelected =state.selectionManager.isSelected(item.key);
272
272
let {rowProps, isPressed} =useTableRow({
273
-
node: item,
274
-
onAction: onAction&& (() =>onAction(item.key))
273
+
node: item
275
274
}, state, ref);
276
275
let {isFocusVisible, focusProps} =useFocusRing();
277
276
@@ -611,10 +610,11 @@ When the `selectionBehavior` prop is set to `"replace"`, clicking a row with the
611
610
612
611
`useTable` may be used in use cases where users can perform actions on rows or cells, such as navigating into items to open them or get more details. In the default `"toggle"` selection behavior, it is recommended to use a link in the first column for navigation.
613
612
614
-
In the `"replace"` selection behavior, the `onAction` prop can be used to enable row and cell actions, which differ depending on the interaction method. When provided to `useTableRow` or `useTableCell`, double clicking with a mouse or pressing the <kbd>Enter</kbd> key triggers `onAction`, while single click and the <kbd>Space</kbd> key are reserved for selection. On touch devices, `onAction` becomes the primary tap interaction, and a long press enters into selection mode, which temporarily swaps the selection behavior to `"toggle"` to perform selection (you may wish to display checkboxes when this happens). Deselecting all items exits selection mode and reverts the selection behavior back to `"replace"`. Double clicking matches the behavior of desktop platforms like macOS and Windows, and a separate selection mode matches mobile platforms like iOS and Android.
613
+
In the `"replace"` selection behavior, the `onRowAction` and `onCellAction` prop can be used to enable row and cell actions, which differ depending on the interaction method. When provided to `useTableState`, double clicking with a mouse or pressing the <kbd>Enter</kbd> key triggers the action, while single click and the <kbd>Space</kbd> key are reserved for selection. On touch devices, the action becomes the primary tap interaction, and a long press enters into selection mode, which temporarily swaps the selection behavior to `"toggle"` to perform selection (you may wish to display checkboxes when this happens). Deselecting all items exits selection mode and reverts the selection behavior back to `"replace"`. Double clicking matches the behavior of desktop platforms like macOS and Windows, and a separate selection mode matches mobile platforms like iOS and Android.
0 commit comments