-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[DataGridPremium] Reordering support for row grouping #18251
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
[DataGridPremium] Reordering support for row grouping #18251
Conversation
Deploy preview: https://deploy-preview-18251--material-ui-x.netlify.app/ Updated pages:
Bundle size report
|
docs/data/data-grid/row-grouping/RowGroupingGroupingValueSetter.tsx
Outdated
Show resolved
Hide resolved
docs/data/data-grid/row-grouping/RowGroupingGroupingValueSetter.tsx
Outdated
Show resolved
Hide resolved
docs/data/data-grid/row-grouping/RowGroupingGroupingValueSetter.tsx
Outdated
Show resolved
Hide resolved
docs/data/data-grid/row-grouping/RowGroupingGroupingValueSetter.tsx
Outdated
Show resolved
Hide resolved
docs/data/data-grid/row-grouping/RowGroupingGroupingValueSetter.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/tests/rowReorder.DataGridPremium.test.tsx
Show resolved
Hide resolved
packages/x-data-grid-premium/src/tests/rowReorder.DataGridPremium.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/tests/rowReorder.DataGridPremium.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-data-grid-premium/src/tests/rowReorder.DataGridPremium.test.tsx
Show resolved
Hide resolved
Great work @MBilalShafi 💯 Screen.Recording.2025-08-25.at.15.10.41.mov |
}; | ||
|
||
// Recursively collect all leaf node IDs from a group | ||
export const collectAllLeafDescendants = ( |
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.
Part of these utilities are similar to the ones used for the automatic parent/child selection.
Maybe in the future we could consider merging them.
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.
Sure, I'll do some reorganizing the in next PR addressing tree-data part. 👍
The issue is also visible here: https://mui.com/x/react-data-grid/row-ordering/#implementing-row-reordering It's reproduced in combination of the setting "When scrolling" in "Show scroll bars" setting. ![]() The scrollbar div overflows on the last cell and prevents the hover to work below that. ![]()
|
Resolves #7775
Preview: https://deploy-preview-18251--material-ui-x.netlify.app/x/react-data-grid/row-grouping/#drag-and-drop-group-reordering
Summary
This PR implements comprehensive drag-and-drop reordering support for row grouping using a two-phase approach: validation and execution.
Architecture
The reordering happens in two steps:
1. Validation Phase (dragOver):
getRowReorderTargetIndex
pipe processor callsrowGroupingReorderValidator
to check operation validity-1
for invalid operations or theplaceholderIndex
for valid onesRowReorderValidator
class2. Execution Phase (dragEnd):
setRowIndex()
triggersrowGroupingReorderExecutor
RowReorderExecutor
classValid Reorder Cases
Invalid Reorder Cases
Core Classes
RowReorderValidator
: Rule-based validation system that checks conditions to determine if a reorder is validRowReorderExecutor
: Manages execution of valid reorder operations with scenario-specific strategiesDrop Indicator Behavior
Updated behavior: Drop indicators now appear for adjacent positions and same-node drops, providing visual feedback even when no actual movement occurs. This improves user experience by showing that the drop zone is recognized.
Logic Splitting
API methods:
Configuration Context provides
useGridRowsOverridableMethods
hook which currently supportssetRowIndex
but could support more methods later. This enables proper logic separation between different hooks and packages.Feature-specific validation:
Uses pipe processing to allow respective hooks (
useGridRowGrouping
,useGridTreeData
, etc.) to inject logic based on requirements. Called fromuseGridRowReorder
hook.I'm not happy with the processor name (
getRowReorderTargetIndex()
) though. Feel free to suggest a better name.Related Updates
groupingValueSetter()
to complementgroupingValueGetter()
for updating grouping fieldsprocessRowUpdate()
is called when row updates happen, allowing users to sync data before updateonProcessRowUpdateError
for failed updatesrowOrderChange
for external handlingCross-Parent Operations
When moving rows between different parent groups, the system automatically updates grouping fields using the configured
groupingValueSetter
or direct field updates, ensuring data consistency.In Progress
processRowUpdate
on group updategroupingValueSetter
(inverse ofgroupingValueGetter
)Show a different cursor (e.g.cursor: not-allowed
) when drop is not applicableOpen questions:
Does it make sense to hide the reorder column if it's not supported, like with sort applied etc.?Follow up
Changelog
🚀 Data Grid row grouping now supports row reordering ([DataGridPremium] Reordering support for row grouping #18251)
See the Drag-and-drop group reordering section for more details.