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] Row spanning #14124

Merged
merged 56 commits into from
Sep 20, 2024
Merged

[DataGrid] Row spanning #14124

merged 56 commits into from
Sep 20, 2024

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Aug 6, 2024

🎉 Feature Completed 🎉

Resolves #207

Based on https://www.notion.so/mui-org/xGrid-Row-Spanning-b178fd43907146799eb7a57d9330b68b?pvs=4#160e28c1b4b247d7befe0cbf44acd475

Documentation and Preview: https://deploy-preview-14124--material-ui-x.netlify.app/x/react-data-grid/row-spanning/

Todos

  • Fix dark mode
  • Recompute on filter
  • Fix keyboard navigation
    • Basic keyboard navigation
    • With column spanning
  • Add support for colDef.valueGetter
  • Add new colDef.colSpanValueGetter for custom use-cases
  • Fix column resize
  • Accessibility improvements
  • Optimize performance
  • Enhance virtualization to honor spanned rows
  • Behavior with editing, should editing a spanned cell update all the associated values, how does a colSpan do?
  • Basic test coverage

Follow-up Todos

  • Add test coverage for more features (e.g. row reordering)
  • Make the Grid remember the last horizontal rowIndex. [DataGrid] Row spanning #14124 (comment)
  • Validate how the feature works with:
    • Cell selection
    • Row selection
  • [TBD] Take into account the column virtualization - only compute row spanning state for rendered columns
  • [TBD] Pin the value exceeding the currently rendered rows on top

Changelog

  • 💫 Support Row spanning on the Data Grid which automatically merges the consecutive cells in a column

    data grid row spanning

@MBilalShafi MBilalShafi added the component: data grid This is the name of the generic UI component, not the React module! label Aug 6, 2024
@MBilalShafi MBilalShafi changed the title [Data Grid] Row spanning POC [DataGrid] Row spanning POC Aug 6, 2024
@mui-bot
Copy link

mui-bot commented Aug 6, 2024

@MBilalShafi MBilalShafi changed the title [DataGrid] Row spanning POC [DataGrid] Row spanning Aug 7, 2024
Copy link
Member Author

Choose a reason for hiding this comment

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

I am wondering what the behavior should be with editing.

Should editing a cell that spans multiple rows update all the repeating values? It makes sense to me.
Although is not how colSpan behaves (example: https://stackblitz.com/edit/react-ucq5za?file=Demo.tsx).

What do you think @mui/xgrid ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand user expectations very well for this feature, but I was wondering if there is a case where users would want to change the value of individual cells that are part of a row span?

Should editing a cell that spans multiple rows update all the repeating values?

If not, this suggestion makes sense to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see use cases for both

  1. If you have structured data and you use rowspan to show value of the parent once for all rows, you would probably want to update all of them at once
  2. If we connected cells in a column for an age, then you probably don't want to update all of them at once

Copy link
Member Author

@MBilalShafi MBilalShafi Aug 19, 2024

Choose a reason for hiding this comment

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

If we connected cells in a column for an age, then you probably don't want to update all of them at once

I believe such rows shouldn't be spanned in the first place. I introduced a prop rowSpanValueGetter to allow excluding unwanted values from being spanned.

For example with age, as you mentioned, it could be the same yet belong to different person. So if we avoid spanning them, we could go with the assumption: editing a cell that spans multiple rows would update all the repeating values

Consider this example: https://deploy-preview-14124--material-ui-x.netlify.app/x/react-data-grid/row-spanning/#customizing-row-spanned-cells

George Floyd and Cynthia Duke are both 25 years old but rowSpanValueGetter is used to correctly span the values.

Does it make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

for our pretty automated feature, this gives enough initial control to cover both cases

Copy link
Member Author

@MBilalShafi MBilalShafi Aug 22, 2024

Choose a reason for hiding this comment

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

After thinking more about this, I'm inclined to not go with this approach for now, mainly because it is a breaking behavioral change.

Currently, on every cell or row update, processRowUpdate prop gets fired once.

If we go with the suggested behavior, the processRowUpdate will get fired more than once each edit (depending on the impacted rows).

The current behavior might also be useful in some cases where the users intend to modify the spanned cells based on the values.

break-spanned-cells.mp4

And the column spanning works in a similar way too, so it should be fine for now.

We might wait for some user feedback around this before deciding to go with the suggested approach. And even if we decide to go with it, we do it at a major, to avoid breaking changes.

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

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 Aug 19, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 20, 2024

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 Aug 20, 2024
@Jcronoxer
Copy link

@MBilalShafi when is the final release of row spanning on the library expected ?

@arminmeh
Copy link
Contributor

Additional points for the follow-up section

  • row selection with row spanning
  • cell selection with row spanning

@MBilalShafi
Copy link
Member Author

  • row selection with row spanning
  • cell selection with row spanning

In my initial testing, the basic cell selection worked fine, did you spot any specific interaction not properly working?
Regarding row selection, I'm not sure tbh if it makes much sense when row spanning is on. IMO we could wait for some feedback to validate if the row selection is actually relevant with the row-spanning feature. Wdyt?

@MBilalShafi
Copy link
Member Author

MBilalShafi commented Sep 18, 2024

@MBilalShafi when is the final release of row spanning on the library expected ?

It should be released this week or coming week.

@arminmeh
Copy link
Contributor

In my initial testing, the basic cell selection worked fine, did you spot any specific interaction not properly working?

Did not test it. I meant more to validate that we want it to behave the way it is (even if it means it can't be used together)

docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
docs/data/data-grid/row-spanning/row-spanning.md Outdated Show resolved Hide resolved
MBilalShafi and others added 4 commits September 20, 2024 05:55
Co-authored-by: Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
@MBilalShafi MBilalShafi enabled auto-merge (squash) September 20, 2024 01:19
@MBilalShafi MBilalShafi merged commit bb30d3a into mui:master Sep 20, 2024
14 of 15 checks passed
@MBilalShafi MBilalShafi deleted the row-spanning branch September 20, 2024 01:52
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Very cool 👍

return (
<div
data-colindex={colIndex}
role="presentation"
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be used, no?

Suggested change
role="presentation"

Looking https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/presentation_role, I see no purpose for the role here.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this seems needed. If I understand https://www.w3.org/WAI/ARIA/apg/practices/hiding-semantics/ correctly, because the parent is a role="row", it needs each child to have a cell role, since this one doesn't have it, it should be hidden.

arthurbalduini pushed a commit to arthurbalduini/mui-x that referenced this pull request Sep 30, 2024
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
Co-authored-by: Sycamore <71297412+samuelsycamore@users.noreply.github.com>
@tomekxoxo
Copy link

tomekxoxo commented Oct 10, 2024

Hello, can you merge this feature to the v5 version of MUI?
Have you tested if export to excel works properly?

@MBilalShafi
Copy link
Member Author

Hey @tomekxoxo,

We only backport critical bug fixes to the previous major versions, I'd suggest you to consider upgrading to a new major.

We have the migration guides available for every major release upgrade. Some of the changes could even be automatically applied using codemods.

Here are the migration guides:
v5 -> v6 migration: mui.com/x/migration/migration-data-grid-v5
v6 -> v7 migration: mui.com/x/migration/migration-data-grid-v6

Have you tested if export to excel works properly

I don't think the row spanning is integrated with Excel export as of now.

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! feature: Row spanning Related to the data grid Row spanning feature new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Implement Row spanning
10 participants