-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[DataGridPro] Fix column reordering on Android #9394
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewNetlify deploy preview: https://deploy-preview-9394--material-ui-x.netlify.app/ Updated pagesNo updates. These are the results for the performance tests:
|
|
packages/grid/x-data-grid-pro/src/hooks/features/columnReorder/useGridColumnReorder.tsx
Outdated
Show resolved
Hide resolved
event.stopPropagation(); | ||
}, []); | ||
const handleDragEnter = useEventCallback( | ||
(params: GridCellParams | GridColumnHeaderParams, event: React.DragEvent) => { |
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.
We can avoid typing arguments here by adding this overload for useEventCallback
that would match the React.useCallback
signature:
declare module '@mui/utils' {
// eslint-disable-next-line @typescript-eslint/naming-convention
export function unstable_useEventCallback<T extends Function>(fn: T): T;
}
Then it will be easier to switch from React.useCallback
to useEventCallback
:
-const handleDragEnter = React.useCallback<
+const handleDragEnter = useEventCallback<
GridEventListener<'cellDragEnter' | 'columnHeaderDragEnter'>
>((params, event) => {
Meanwhile, I'll add this overload for unstable_useEventCallback
in the core repo.
Co-authored-by: Andrew Cherniavskii <[email protected]> Signed-off-by: Matheus Wichman <[email protected]>
packages/grid/x-data-grid-pro/src/hooks/features/columnReorder/useGridColumnReorder.tsx
Outdated
Show resolved
Hide resolved
…/useGridColumnReorder.tsx Co-authored-by: Danail Hadjiatanasov <[email protected]> Signed-off-by: Matheus Wichman <[email protected]>
packages/grid/x-data-grid-pro/src/hooks/features/columnReorder/useGridColumnReorder.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Matheus Wichman <[email protected]>
@cherniavskii could you test again on iOS? After changing the MIME type to |
I've checked different MIME types on iOS 16.5.1:
|
event.clientY < rect.top || | ||
event.clientY > rect.bottom; |
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.
Unfortunately, this doesn't work in Safari.
For some reason, clientX
/clientY
values are wrong during the dragend
event:
safari-clientY.mov
I've found a similar issue mentioned here:
the clientX/screenX and clientY/screenY coordinates are simply wrong. I have no idea what they report. They don't even depend on where you touch.
https://horstmann.com/unblog/2018-12-16/index.html
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.
I tried text/x-data-grid
and it also doesn't work on Android. I don't know which MIME type to use since no one works correctly in both platforms. I think it would be better to ditch the HTML drag'n'drop API on mobile and use touch events like https://github.com/react-dnd/react-dnd/ does.
@cherniavskii could you test again? I added a condition to use different MIME types depending on the platform. |
@m4theushw Yes, the MIME type works in both Safari and Chrome on iOS. |
@cherniavskii @DanailH does it make sense to keep this PR? |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Partially fixes #9330
Preview: https://deploy-preview-9394--material-ui-x.netlify.app/x/react-data-grid/column-ordering/