Datagrid focus on cells #3774
-
Hi there, we are using a data grid for its sorting capabilities and row actions but have noticed in our implementation and on the Paste website that there's a focus state on any cell that is clicked in the table, even if there isn't an actionable/interactive item in the cell. Wanted to understand if this is intended behavior. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
🤖 Hey @darcimm! Great to see you back. 😊 I remember our last cosmic dance through the code. I'm diving into your datagrid conundrum now and will orbit back with insights soon! |
Beta Was this translation helpful? Give feedback.
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Hi Darci, Yes, the focus state on any cell that is clicked in the table is intended behavior. This is part of the Data Grid's full keyboard navigation functionality. When in Navigational mode, data cells can be focused using standard navigation keys, and clicking on a cell will also focus it. This allows users to navigate the Data Grid using the keyboard, which is an accessibility feature. Here's a snippet from the documentation regarding Navigational mode:
For more information on keyboard navigation and the Data Grid component, you can visit the Paste documentation:
I hope this helps clarify the behavior you're observing! Best, I also did a search, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
🤖 Yes, the focus state on any cell in the data grid, even if there isn't an actionable/interactive item in the cell, is indeed an intended behavior of the Paste design system. This is part of the Data Grid's full keyboard navigation functionality, which is an accessibility feature. The DataGridCell component in the Paste design system has a const handleMouseDown = React.useCallback(() => {
ensureFocus(cellRef.current);
}, []); The The In addition, the const onListMutation = React.useCallback(
(mutationList: MutationRecord[]) => {
//...
if (
mutation.attributeName === "tabindex" &&
dataGridState.actionable &&
target.tabIndex === 0 &&
isCell(target)
) {
target.tabIndex = -1;
}
//...
},
[dataGridState.actionable],
);
React.useEffect(() => {
setTimeout(() => {
if (cellRef.current) {
updateTabIndexForActionable(cellRef.current, dataGridState.actionable);
}
}, 10);
}, [dataGridState.actionable]); You can find more information about this in the DataGridCell component and the ensureFocus utility function in the Paste repository. I hope this helps clarify the behavior you're observing! If you have any more questions, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the detailed answer!! Is there a way to disable the "Navigational mode" on the datagrid, such that you can keyboard navigate only to interactive elements and therefore the focus state doesn't appear on non-interactive cells? |
Beta Was this translation helpful? Give feedback.
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary.
Hi Darci,
Yes, the focus state on any cell that is clicked in the table is intended behavior. This is part of the Data Grid's full keyboard navigation functionality. When in Navigational mode, data cells can be focused using standard navigation keys, and clicking on a cell will also focus it. This allows users to navigate the Data Grid using the keyboard, which is an accessibility feature.
Here's a snippet from the documentation regarding Navigational mode: