-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Allows keyboard navigation in group header #5947
Conversation
These are the results for the performance tests:
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! The only thing I would consider adding is a check if a column header doesn't have content (it's empty) not to be able to navigate in it. Idk how difficult lit would be tho.
}); | ||
}, [apiRef, props.columnGroupingModel]); | ||
|
||
useGridApiEventHandler(apiRef, 'columnOrderChange', handleColumnReorderChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be handled in the useGridColumnReorder
hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because the useGridColumnReorder
trigger the event, then other hooks listen to it, like the useGridcolumnSpanning
, or useGridcolumnPinning
which already listen tot this event to recompute their state
Did you had a specific idea in mind like performance impact for putting the logic in the useGridColumnReorder
?
@@ -103,15 +48,6 @@ const createGroupLookup = (columnGroupingModel: GridColumnNode[]): GridColumnGro | |||
|
|||
return { ...groupLookup }; | |||
}; | |||
export const columnGroupsStateInitializer: GridStateInitializer< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be lost but does this mean that the groups are no longer persisted in the state? Shouldn't we initialize an empty columnGrouping
state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unclear for me when an initializer is necessary. I thaught it was used to initialise the state before pipe processors are called.
Since column grouping is not used by any processors, I removed the initialization. But if it's needed for other purpose, I can bring initializer back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main purpose of the state initializers was to allow the state to be initialized synchronously before any feature hook. Later, we had to also initialize them before any pre-processor. You can delete the state initializer and have the feature working normally. The React.useEffect
in this hook will take care of initializing the state, but it will happen asynchronously now. This will only be a problem if another hook depends on the state of the column grouping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, since the state is reused by columnReorder
and columnHeader
I put back the initializer
@DanailH It was my first it do not navigate to empty cell but then comes the question about where does the focus go. And their is no obvious answer to that, so I looked at other libraries, and they just let navigate in empty column group. For example AG grid column group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! I didn't thing any bug related to keyboard navigation, although I noticed a small problem when the user hides a column in https://deploy-preview-5947--material-ui-x.netlify.app/x/react-data-grid/column-groups/.
msedge_dJb50P4sDK.mp4
I can't reproduce it in https://docs-next--material-ui-x.netlify.app/x/react-data-grid/column-groups/ so it propabily was added in this PR.
packages/grid/x-data-grid/src/hooks/features/keyboardNavigation/useGridKeyboardNavigation.ts
Outdated
Show resolved
Hide resolved
packages/grid/x-data-grid/src/hooks/features/keyboardNavigation/useGridKeyboardNavigation.ts
Outdated
Show resolved
Hide resolved
@m4theushw the bug is fixed by this commit I was rendering all the column groups between the first and last columns to render. Now I remove groups that have all their columns hidden |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Preview: https://deploy-preview-5947--material-ui-x.netlify.app/x/react-data-grid/column-groups/
The structure column group structure was shared between columns definitions and the columnGroups state.
In this PR I move the
column.groupPath
which contains the list of the group parent into a methodunstable_getColumnGroupPath(field)
ANd the all group header structure is saved in the state. The idea being to simplify query such as "What is the group on the left of the focused one" and later on for groups drag and drop: "What are the children of their dragged group and the children of the drop group"