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] Add indexes relative to the filtered rows and the current page to the getRowClassName and getRowSpacing props #3882

Merged
merged 46 commits into from
Apr 11, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Feb 7, 2022

Fixes #2334

Add two params to GridRowVisibilityParams, which is passed to props.getRowClassName and props.getRowSpacing:

  • indexRelativeToExpandedRows
  • indexRelativeToCurrentPage

@mui-bot
Copy link

mui-bot commented Feb 7, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 245.6 588.5 418.2 401.04 137.234
Sort 100k rows ms 461.8 1,034.6 729.4 779.26 190.428
Select 100k rows ms 127.2 219.3 177.3 172.28 37.976
Deselect 100k rows ms 98.2 295.2 221.2 196.18 67.821

Generated by 🚫 dangerJS against 36069be

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

About naming, the xxxRows let me expect an array, whereas it is a number.

Maybe indexes.visibleIndex or indexes.fromVisibleRows

For the demo position, it looks good to me

docs/src/pages/components/data-grid/style/StripedGrid.tsx Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/components/GridRow.tsx Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/components/GridRow.tsx Outdated Show resolved Hide resolved
@flaviendelangle
Copy link
Member Author

@alexfauquette I went for indexes.fromFilteredRows and index.fromPageRows

[`& .${gridClasses.row}.even`]: {
backgroundColor: '#EEEEEE',
'&:hover, &.Mui-hovered': {
backgroundColor: alpha(theme.palette.primary.main, ODD_OPACITY),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
backgroundColor: alpha(theme.palette.primary.main, ODD_OPACITY),
backgroundColor: '#E0E0E0',

The hover should move from light to darker gray. Here I propose the hover moves from grey-200 to grey-300 according to https://material.io/resources/color/#!/?view.left=0&view.right=0&primary.color=bcbcbc

Copy link
Member Author

Choose a reason for hiding this comment

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

How do you make the hover and / or selected consistent with this color ?

Copy link
Member

Choose a reason for hiding this comment

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

Should we? For now, we have two colors: palette.action.hover for unselected rows (with hover), and palette.primary.main for selected ones. The distinction between hover and not hover is done by managing opacity for the selected rows.

Here are the colors for each configuration, and the cell with a "?" is the one we are discussing.

For sure it should not be computed from palette.primary.main which is reserved for selected rows. But how to get similar color variation on hover, I don't know

state odd color even color
normal white(undefined) grey-200
hover grey-100 ?
selected main color & opacity main color & opacity+
selected+hover main color & opacity+ main color & opacity++

@siriwatknp
Copy link
Member

siriwatknp commented Feb 8, 2022

👋 The migration PR has been merged.

Please follow these steps to make sure that the contents are all updated. (Sorry for the inconvenience)

  1. pull latest master from upstream to your branch
  2. if your PR has changes on the *.md or demo files, you are likely to encounter conflict because all of them have been moved to the new folder.
    2.1 revert the change on those markdown files you did
    2.2 pull latest master from upstream (you should not see conflict)
    2.3 make the changes again at docs/data/data-grid/*
  3. run yarn docs:api
    • you might see the changes in docs/pages/x/api/data-grid/* if your PR touches some of the components
    • it is okay if there is no changes

If you are struggle with the steps above, feel free to tag @siriwatknp

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 8, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 8, 2022
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 17, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@flaviendelangle flaviendelangle added the on hold There is a blocker, we need to wait label Feb 18, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 29, 2022
@flaviendelangle flaviendelangle added component: data grid This is the name of the generic UI component, not the React module! and removed on hold There is a blocker, we need to wait labels Mar 29, 2022
@flaviendelangle flaviendelangle changed the title [DataGrid] Pass the indexes relative to the filtered rows and the current page to the getRowClassName callback [DataGrid] Pass the indexes relative to the filtered rows and the current page to the getRowClassName and getRowSpacing props Mar 30, 2022
@flaviendelangle flaviendelangle changed the title [DataGrid] Pass the indexes relative to the filtered rows and the current page to the getRowClassName and getRowSpacing props [DataGrid] Add indexes relative to the filtered rows and the current page to the getRowClassName and getRowSpacing props Mar 30, 2022
Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

Which problem indexRelativeToExpandedRows is solving? I can't remember it.

docs/data/data-grid/style/style.md Show resolved Hide resolved
docs/data/data-grid/style/style.md Outdated Show resolved Hide resolved
@flaviendelangle
Copy link
Member Author

Which problem indexRelativeToExpandedRows is solving? I can't remember it.

Initially I did a prop so I kept the indexRelativeToExpandedRows which was the equivalent of the current props.index in GridRow.
But for the params of getRowClassName or getRowSpacing I don't have a real use-case in mind.
Some users might want to style based on the all-page-index, but that's probably not a frequent use-case.

We can leave it, as it does not bring a lot of additional complexity.
Or remove it and add if somebody asks for it later.

Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

LGTM. You can decide to keep or not indexRelativeToExpandedRows.

@flaviendelangle
Copy link
Member Author

I removed it
Let's wait for a concrete use case, adding it will be very easy

@github-actions
Copy link

github-actions bot commented Apr 9, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 9, 2022
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 11, 2022
@flaviendelangle flaviendelangle merged commit 4f2c9a5 into mui:master Apr 11, 2022
@flaviendelangle flaviendelangle deleted the striped-rows branch April 11, 2022 08:34
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
…page to the `getRowClassName` and `getRowSpacing` props (mui#3882)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Add API to style even and odd rows differently
5 participants