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] Improve the handling of events (rm capture, add event, add new props) #1158

Merged
merged 22 commits into from
Mar 11, 2021

Conversation

dtassone
Copy link
Member

@dtassone dtassone commented Mar 3, 2021

Breaking Changes

  • [DataGrid] Rename event handlers for consistency
-<DataGrid onCellHover
-<DataGrid onRowHover
+<DataGrid onCellOver
+<DataGrid onRowOver

Fix #1157
Fix #1108
Fix #273
Related to #947

TODO:

  • update the api docs
  • cell events (click, double click, over, out, enter, leave)
  • row events (click, double click, over, out, enter, leave)
  • column header events (click, double click, over, out, enter, leave)
  • add tests

@dtassone dtassone marked this pull request as draft March 3, 2021 18:27
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.

I like the idea of using the synthetic event system of React rather than a native event. This should help/solve #891.

@dtassone dtassone closed this Mar 3, 2021
@dtassone dtassone reopened this Mar 3, 2021
@dtassone
Copy link
Member Author

dtassone commented Mar 5, 2021

Should we bind the events if there is a renderCell? How about with a renderEditCell?
We could leave that up to the customization?

@oliviertassinari oliviertassinari changed the title [DataGrid] remove event capture [DataGrid] Remove event capture Mar 5, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 6, 2021

Should we bind the events if there is a renderCell? How about with a renderEditCell?
We could leave that up to the customization?

If we keep renderCell and renderEditCell customizing the children of a cell, not the Cell itself, I think that we should keep the binding of the events in the internal of the data grid. So no.

By removing the event capture, we make it possible for developers to hook into event.nativeEvent inside the cells (not the whole Cell but the children).
If we move the event listener to the synthetic event system of React, we would remove the need to access .nativeEvent.

As a side note, it might be interesting to add a test case where we click in a button on a cell, add something in the event, and see this something available in the onRowClick/onCellClick listeners. It gets us one step closer to solving #891

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Mar 6, 2021
@dtassone dtassone marked this pull request as ready for review March 8, 2021 15:50
@dtassone dtassone changed the title [DataGrid] Remove event capture [DataGrid] Refactor events, rm capture, allow stop propagation, add enter leave out Mar 8, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] Refactor events, rm capture, allow stop propagation, add enter leave out [DataGrid] Improve the handling of DOM events (rm capture, expose event, add new ones) Mar 8, 2021
@oliviertassinari oliviertassinari changed the title [DataGrid] Improve the handling of DOM events (rm capture, expose event, add new ones) [DataGrid] Improve the handling of events (rm capture, add event, add new props) Mar 8, 2021
@dtassone
Copy link
Member Author

dtassone commented Mar 8, 2021

Issue with the event serialisation on commodity dataset

@dtassone
Copy link
Member Author

dtassone commented Mar 9, 2021

I did some improvements on the storybook.
Check the story below, and the control tab to change the number of rows...
https://deploy-preview-1158--material-ui-x.netlify.app/storybook/?path=/story/x-grid-demos-playground--demo

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.

You can use the documentation that Sebastian has added to debug the failing visual repression tests: https://github.com/mui-org/material-ui/blob/next/test/README.md#run-the-visual-regression-tests

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.

We need to update the API pages. Hopefully, this pain with incentivize us to work on its automatic generation.

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.

Nice a large refactoring 😁

packages/grid/_modules_/grid/models/api/gridParamsApi.ts Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/models/api/gridParamsApi.ts Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/models/api/gridParamsApi.ts Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/models/api/gridParamsApi.ts Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/models/api/gridParamsApi.ts Outdated Show resolved Hide resolved
packages/grid/x-grid/src/tests/events.XGrid.test.tsx Outdated Show resolved Hide resolved
packages/grid/x-grid/src/tests/events.XGrid.test.tsx Outdated Show resolved Hide resolved
packages/grid/_modules_/grid/utils/domUtils.ts Outdated Show resolved Hide resolved
packages/storybook/src/stories/grid-columns.stories.tsx Outdated Show resolved Hide resolved
dtassone and others added 4 commits March 11, 2021 14:21
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
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.

Great

@tusharchutani
Copy link

Just curious when will this be released?

This was referenced Mar 25, 2021
@dtassone
Copy link
Member Author

Just curious when will this be released?

v4.0.0-alpha-23 should be released already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
5 participants