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] Custom Columns: How to improve usability of the Date Picker in a narrow column #13079

Closed
theobrasseurbentley opened this issue May 10, 2024 · 6 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! component: date picker This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ support: question Community support but can be turned into an improvement

Comments

@theobrasseurbentley
Copy link

theobrasseurbentley commented May 10, 2024

The problem in depth

Using the demo: https://mui.com/x/react-data-grid/custom-columns/#date-pickers

  1. Make the date column resizable: true
  2. Shrink the column until the date is only partially visible
  3. Edit the date

It is hard to enter a date in full. How to make it easier?
The normal edit cell behaves better.

Your environment

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

Search keywords: Custom Columns DatePicker
Order ID: 82553

@theobrasseurbentley theobrasseurbentley added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels May 10, 2024
@michelengelen michelengelen added support: question Community support but can be turned into an improvement component: pickers This is the name of the generic UI component, not the React module! support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ component: date picker This is the name of the generic UI component, not the React module! component: data grid This is the name of the generic UI component, not the React module! and removed component: pickers This is the name of the generic UI component, not the React module! labels May 13, 2024
@michelengelen
Copy link
Member

Hey @theobrasseurbentley
thanks for opening an issue for this.
I am not sure if we can support an improvement on this at the moment.
One way would be to render the editing component inside of a popper that anchors on the top-left corner of the cell.
Let me give this a shot.

@michelengelen
Copy link
Member

OK, so I did play around with this a bit and it is not possible with the current version. We would need a ref for the Popper to know where to render. We could actually do this when we would pass the cellRef into the GridRenderEditCellParams like this:

diff --git a/packages/x-data-grid/src/components/cell/GridCell.tsx b/packages/x-data-grid/src/components/cell/GridCell.tsx
index 81a23061e..fb1cf8e9b 100644
--- a/packages/x-data-grid/src/components/cell/GridCell.tsx
+++ b/packages/x-data-grid/src/components/cell/GridCell.tsx
@@ -429,6 +429,7 @@ const GridCell = React.forwardRef<HTMLDivElement, GridCellProps>((props, ref) =>
       row: updatedRow,
       formattedValue,
       ...editCellStateRest,
+      ref: cellRef,
     };

     children = column.renderEditCell(params);

that way we would also be able to provide some more flexibility in rendering edit cells.
I am not sure if this might have some performance implications.

Thoughts @cherniavskii or @romgrk ?

@michelengelen michelengelen changed the title [question] Custom Columns: How to improve usability of the Date Picker in a narrow column [data grid] Custom Columns: How to improve usability of the Date Picker in a narrow column May 13, 2024
@michelengelen
Copy link
Member

@theobrasseurbentley ... the best way would probably be to assign a minWidth to the cols that have the date or dateTime type.

const columns: GridColDef[] = [
  // ...
  {
    field: 'createdAt',
    headerName: 'Created at',
    type: 'date',
    minWidth: 180,
    editable: true,
  },
  // ...
];

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 14, 2024
@michelengelen
Copy link
Member

Hey @theobrasseurbentley ... I did find a solution with Popper that works: Example

Let me know what you think! 👍🏼

@theobrasseurbentley
Copy link
Author

Thank you @michelengelen !
I think these solutions have merit.
Going with the min width for now.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 14, 2024
@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 14, 2024
Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@theobrasseurbentley: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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! component: date picker This is the name of the generic UI component, not the React module! support: commercial Support request from paid users support: premium standard Support request from a Premium standard plan user. https://mui.com/legal/technical-support-sla/ support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants