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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column resizing on mobile does not work correctly and width scales inversely #4417

Closed
2 tasks done
jameswilliams-modality opened this issue Apr 9, 2022 · 1 comment 路 Fixed by #5056
Closed
2 tasks done
Assignees
Labels
bug 馃悰 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user

Comments

@jameswilliams-modality
Copy link

jameswilliams-modality commented Apr 9, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 馃槸

Column resizing on mobile use touch input does not work correctly and width scales inversely.

Expected behavior 馃

Column resizing on mobile using touch input should work the same as using the mouse pointer.

Steps to reproduce 馃暪

Steps:

  1. Open https://codesandbox.io/s/columnsizinggrid-material-demo-forked-i9n5jr
  2. If you are not on a touch enabled device, switch to mobile / responsive mode to emulate touch input with the pointer.
  3. Attempt to resize the columns on the commercial data grid example using touch input.
  4. Note that the column width is not computed correctly and scales inversely and non-linearly.

Context 馃敠

The root cause is that columnSeparator inner svg captures the touch event instead of the columnSeparator div, getSeparatorSide doesn't match the columnSeparator--sideRight grid class as the element is the svg instead ofthe div, separatorSide is set to 'left', and computeNewWidth adds the wrong width increment to initialOffsetToSeparator.

I have resolved this for now by disabling pointer events on the svg

'& .MuiDataGrid-columnSeparator--resizable svg': {
  pointerEvents: 'none',
},

using the sx prop on DataGrid.

History of other issues relating to column resizing on mobile (none that describe the current issue)

Your environment 馃寧

`npx @mui/envinfo`
System:
  OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
Binaries:
  Node: 16.14.2 - /usr/bin/node
  Yarn: 1.22.18 - /usr/bin/yarn
  npm: 8.5.0 - /usr/bin/npm
Browsers:
  Chrome: 100.0.4896.75
  Firefox: 99.0
npmPackages:
  @emotion/react: ^11.7.0 => 11.9.0 
  @emotion/styled: ^11.6.0 => 11.8.1 
  @mui/base:  5.0.0-alpha.75 
  @mui/icons-material: ^5.2.1 => 5.6.0 
  @mui/material: ^5.2.3 => 5.6.0 
  @mui/private-theming:  5.6.0 
  @mui/styled-engine:  5.6.0 
  @mui/styles: ^5.2.3 => 5.6.0 
  @mui/system:  5.6.0 
  @mui/types:  7.1.3 
  @mui/utils:  5.6.0 
  @mui/x-data-grid:  5.8.0 
  @mui/x-data-grid-pro: ^5.8.0 => 5.8.0 
  @mui/x-license-pro:  5.7.0 
  @types/react:  18.0.0 
  react: ^17.0.2 => 17.0.2 
  react-dom: ^17.0.2 => 17.0.2 

Order ID 馃挸 (optional)

#41445

@jameswilliams-modality jameswilliams-modality added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 9, 2022
@cherniavskii
Copy link
Member

Hey @jameswilliams-modality
Thanks for raising this issue.

Would you like to submit a pull request?
Adding pointerEvents: none indeed fixes the issue:

--- a/packages/grid/x-data-grid/src/components/containers/GridRootStyles.ts
+++ b/packages/grid/x-data-grid/src/components/containers/GridRootStyles.ts
@@ -187,6 +187,9 @@ export const GridRootStyles = styled('div', {
       [`&.${gridClasses['columnSeparator--resizing']}`]: {
         color: theme.palette.text.primary,
       },
+      '& svg': {
+        pointerEvents: 'none',
+      },
     },
     [`& .${gridClasses.iconSeparator}`]: {

@cherniavskii cherniavskii added bug 馃悰 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Other and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 18, 2022
@m4theushw m4theushw added good first issue Great for first contributions. Enable to learn the contribution process. and removed good first issue Great for first contributions. Enable to learn the contribution process. labels May 18, 2022
@cherniavskii cherniavskii self-assigned this May 24, 2022
@cherniavskii cherniavskii added the plan: Pro Impact at least one Pro user label May 31, 2022
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! plan: Pro Impact at least one Pro user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants