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

onCellClick is not triggered on last row cell (extend row full width cell) #4316

Closed
2 tasks done
ak-mid opened this issue Mar 30, 2022 · 4 comments
Closed
2 tasks done
Labels
component: data grid This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@ak-mid
Copy link

ak-mid commented Mar 30, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

The last cell which only extends the row to reach full width isn't triggering the onCellClick callback.
In my layout most data grids are full width so in cases with only a few columns the last cell might be the biggest and therefore it's possible that a user clicks on it.

Why I don't use onRowClick:
Previously I was redirecting my users onRowClick to a details view of the grid entry.
Due to a change onRowClick started to also triggered when selecting a grid entry via checkbox #3805 so I needed to replace it with onCellClick to imitate the old behavior.

Expected behavior 🤔

The last cell should also triggering onCellClick callback.

Steps to reproduce 🕹

Steps:

Context 🔦

No response

Your environment 🌎

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

Order ID 💳 (optional)

35878

@ak-mid ak-mid added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 30, 2022
@DanailH
Copy link
Member

DanailH commented Mar 31, 2022

Please provide a minimal reproduction test case with the latest version. This would help a lot 👷 .
A live example would be perfect. This codesandbox.io template may be a good starting point. Thank you!

@DanailH DanailH added the status: waiting for author Issue with insufficient information label Mar 31, 2022
@ak-mid
Copy link
Author

ak-mid commented Mar 31, 2022

I've added a codesandbox example here:

https://codesandbox.io/s/datagrid-v5-quick-start-forked-u47dhv?file=/src/App.tsx

I activated disableExtendRowFullWidth so it's more visible what I'm talking about.
It's about the cells on the right side of the disableExtendRowFullWidth border.

image

When you click on one of those cells onCellClick is not triggered. In my codesandbox example the alert box is not showing up.

@alexfauquette
Copy link
Member

For the long term, it sounds this issue is related to #4308 This problem would not occur if the last column was extended to fill the remaining space

For a faster solution, the component you want to click on is not a cell so it should not trigger the cellClick. Otherwise, it would impact also the focus and maybe other features. And it would be misleading for other users that onCellClick is called when clicking outside of a cell.

I can propose you some work arounds

@alexfauquette alexfauquette added support: question Community support but can be turned into an improvement 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 status: waiting for author Issue with insufficient information labels Apr 4, 2022
@ak-mid
Copy link
Author

ak-mid commented Apr 4, 2022

For the long term, it sounds this issue is related to #4308 This problem would not occur if the last column was extended to fill the remaining space

That would probably the best solution.

Your problem with rowClick has been fixed.

I didn't notice that - Thanks for the hint! I switched back to onRowClick because adding an action button to redirect the user IMO would be bad usability as the button might be no visible in the viewport (especially on small resolutions).

@ak-mid ak-mid closed this as completed Apr 4, 2022
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! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants