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

[data grid] columnResizeStop is not emitted when column isn't resized #13178

Open
lauri865 opened this issue May 19, 2024 · 3 comments · May be fixed by #13307
Open

[data grid] columnResizeStop is not emitted when column isn't resized #13178

lauri865 opened this issue May 19, 2024 · 3 comments · May be fixed by #13307
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column resize good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@lauri865
Copy link
Contributor

lauri865 commented May 19, 2024

Steps to reproduce

Link to live example: (required)

Steps:

  1. https://mui.com/x/react-data-grid/
  2. Pick the first datagrid and just click on the column resizer
  3. After the click, witness how column resizer stays in the active state (brighter highlight in dark mode)
Screenshot 2024-05-19 at 22 51 13

Current behavior

Column resizer gets stuck in the active state

Expected behavior

Column resizer should revert to non-active state.

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: columnResizeStop

@lauri865 lauri865 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 19, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label May 20, 2024
@michelengelen
Copy link
Member

Hey @lauri865
Thanks for raising this. I can confirm this bug and there is a simple solution for this:

diff --git a/packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx b/packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx
index e4d3c51d9..475938741 100644
--- a/packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx
+++ b/packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx
@@ -422,6 +422,7 @@ export const useGridColumnResize = (
         nativeEvent.clientY === prevClientY
       ) {
         refs.previousMouseClickEvent = undefined;
+        apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
         return;
       }
     }

BUT: the check for the double click event seems as if it is inefficient. When clicking only once the previous event will be the mousedown event and we are checking basically if the mouseup event is following in under 300 ms.

@mui/xgrid WDYT?

@michelengelen michelengelen added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. feature: Column resize and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 21, 2024
@michelengelen michelengelen changed the title [Datagrid] columnResizeStop is not emitted when column isn't resized [data grid] columnResizeStop is not emitted when column isn't resized May 21, 2024
@mateuseap
Copy link

Hi! I'd like to know if I can open a PR for this one :)

@romgrk
Copy link
Contributor

romgrk commented May 30, 2024

Hey! Yes you can take this one.

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! feature: Column resize good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants