-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[DataGridPro] Fix duplicate nested rows for dynamically updated row IDs #18526
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
base: master
Are you sure you want to change the base?
[DataGridPro] Fix duplicate nested rows for dynamically updated row IDs #18526
Conversation
Deploy preview: https://deploy-preview-18526--material-ui-x.netlify.app/ Bundle size reportTotal Size Change: 🔺+2.26KB(+0.02%) - Total Gzip Change: 🔺+839B(+0.02%) Show details for 100 more bundles (22 more not shown)@mui/x-data-grid parsed: 🔺+377B(+0.10%) gzip: 🔺+147B(+0.13%) |
if (groupKeys && groupKeys.length > 0) { | ||
const rootNode = tree[GRID_ROOT_GROUP_ID]; | ||
let parentNode = rootNode; | ||
for (let i = 0; i < groupKeys.length; i += 1) { | ||
const childrenFromPath = (parentNode as GridGroupNode).childrenFromPath; | ||
const nodeId = childrenFromPath[Object.keys(childrenFromPath)[0]]?.[groupKeys[i]]; | ||
if (nodeId) { | ||
parentNode = tree[nodeId]; | ||
} | ||
} | ||
|
||
const traverse = (node: GridGroupNode) => { |
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.
Why is this whole traverse necessary?
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 is to check if the children of the row being fetched are outdated and need to be removed before adding new ones.
Regarding the part where parent group's ID is derived from groupKeys
: we could update the function signature to directly accept parent id. However, since the current approach isn’t expensive (by leveraging childrenFromPath
), I chose not to modify the signature. What do you think about this approach vs changing the function signature (will be a non-breaking change as the function is private)?
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com> Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
Reported in https://mui.zendesk.com/agent/tickets/28655
Reproduction Tree Data: https://stackblitz.com/edit/vwnrw8kg?file=src%2FDemo.tsx
Reproduction Row Grouping: https://stackblitz.com/edit/cqu1xgfv?file=src%2FDemo.tsx
For the nested Data Source rows (tree data and row grouping), if the IDs of rows are constantly updating the Data Grid treats them as new rows and doesn't remove the previous ones. This PR aims to fix that.