Skip to content
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] Extract getRowId API method as a selector #16487

Merged
merged 17 commits into from
Feb 13, 2025

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Feb 6, 2025

Fixes #16103

Fixes #16413

Better fix for #14691

Reuses the props state logic initially committed in #12343

Changelog

  • Deprecate getRowId API method. gridRowIdSelector should be used instead.
  • Deprecate getRowNode API method. gridRowNodeSelector should be used instead.

@MBilalShafi MBilalShafi added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Tree data Related to the data grid Tree data feature feature: Row grouping Related to the data grid Row grouping feature feature: Aggregation Related to the data grid Aggregation feature feature: Row spanning Related to the data grid Row spanning feature needs cherry-pick The PR should be cherry-picked to master after merge v7.x labels Feb 6, 2025
@@ -112,18 +113,11 @@ export const useGridRows = (
[apiRef],
);

const getRowIdProp = props.getRowId;
const getRowId = React.useCallback<GridRowApi['getRowId']>(
Copy link
Member Author

@MBilalShafi MBilalShafi Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts about deprecating it in favor of the added utility?
Deprecated in favor of the new selector gridRowIdSelector
We could remove all internal instances later.

@mui-bot
Copy link

mui-bot commented Feb 6, 2025

Deploy preview: https://deploy-preview-16487--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against fd2c51e

@MBilalShafi MBilalShafi requested a review from a team February 6, 2025 11:43
@MBilalShafi MBilalShafi changed the title [DataGrid] Extract getRowId API method as static function [DataGrid] Extract getRowId API method as a selector Feb 6, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 10, 2025

This comment was marked as outdated.

@cherniavskii cherniavskii self-requested a review February 10, 2025 14:15
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 10, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure about deprecating these? 🤔
Discovering and calling a method is much easier than discovering the selector and importing it.

Copy link
Member Author

@MBilalShafi MBilalShafi Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discovering and calling a method is much easier than discovering the selector and importing it.

It's a good point.

Here are the arguments I have in mind in favor of the deprecation:

  1. Both getRowId and getRowNode are meant to be used internally more than 90% of the times and having API methods for them kind-of feels redundant.
  2. Less API surface (especially for the cases where there's an easy workaround) is always better for maintainability etc.
  3. Using selectors is not something that we rarely use now, after the reactivity improvements, it's been used very frequently at multiple places, I'd personally try to use documentation to elaborate the use of those selectors to solve the discoverability, if we feel a knowledge gap.

Since we are deprecating them and not removing them until next major, if there's a discoverability pain reported by a noticeable number of users we can always bring them back. (We could avoid deprecating them in v7) Wdyt?

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 13, 2025

This comment was marked as outdated.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 13, 2025
@MBilalShafi MBilalShafi enabled auto-merge (squash) February 13, 2025 12:29
@MBilalShafi MBilalShafi merged commit 9c62a6c into mui:master Feb 13, 2025
16 checks passed
Copy link

Cherry-pick PRs will be created targeting branches: v7.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Aggregation Related to the data grid Aggregation feature feature: Row grouping Related to the data grid Row grouping feature feature: Row spanning Related to the data grid Row spanning feature feature: Tree data Related to the data grid Tree data feature needs cherry-pick The PR should be cherry-picked to master after merge v7.x
Projects
None yet
5 participants