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

[DataGrid] Column menu visual updates #8424

Closed

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Mar 29, 2023

Context: #6619 (comment)
Preview: https://deploy-preview-8424--material-ui-x.netlify.app/x/react-data-grid/column-menu/#column-menu-with-pro-premium-features

Changelog

  • Remove the hover background and pointer cursor from the aggregation item
  • Remove the minWidth constraint from smaller screens
  • Add mui-fixed class on the menu to remove flicker on open/close

@MBilalShafi MBilalShafi added component: data grid This is the name of the generic UI component, not the React module! design: ux labels Mar 29, 2023
@MBilalShafi MBilalShafi self-assigned this Mar 29, 2023
@mui-bot
Copy link

mui-bot commented Mar 29, 2023

Netlify deploy preview

Netlify deploy preview: https://deploy-preview-8424--material-ui-x.netlify.app/

Updated pages

No updates.

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 608.7 1,037.3 630.7 769.58 153.257
Sort 100k rows ms 552.3 1,015.7 683.6 793.36 160.35
Select 100k rows ms 173.4 281.2 214.5 219.8 34.755
Deselect 100k rows ms 138.6 235 179.4 187.36 32.057

Generated by 🚫 dangerJS against 1c7a05d

@MBilalShafi MBilalShafi changed the title [DataGrid] Fix aggregation column menu item causing the body scroll to jump [DataGrid] Column menu visual updates Mar 31, 2023
@MBilalShafi MBilalShafi marked this pull request as ready for review March 31, 2023 04:31
Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

value={selectedAggregationRule}
label={label}
native
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid using native here and fix the column menu shift with mui-fixed class - see https://mui.com/material-ui/getting-started/faq/#why-do-the-fixed-positioned-elements-move-when-a-modal-is-opened

diff --git a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnHeaderMenu.tsx b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnHeaderMenu.tsx
index 5c067a68b..a7027d560 100644
--- a/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnHeaderMenu.tsx
+++ b/packages/grid/x-data-grid/src/components/menu/columnMenu/GridColumnHeaderMenu.tsx
@@ -51,6 +51,7 @@ function GridColumnHeaderMenu({
       target={target}
       onClickAway={hideMenu}
       onExited={onExited}
+      className="mui-fixed"
     >
       <ContentComponent
         colDef={colDef}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened an issue in the core repo: mui/material-ui#37207

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't guess the reason but it got reproduced again on opening the context menu

column-menu

Copy link
Member

@oliviertassinari oliviertassinari May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce this one on macOS & Chrome.

Copy link
Member Author

@MBilalShafi MBilalShafi Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, mostly it's reproducible on Firefox (Mac OS), to reproduce on Chrome, I had to follow these steps:

  1. Open aggregation menu item
  2. Right-click to open the context menu
  3. Click on some other window, say VS Code, to defocus the browser.

Maybe the case is very less likely, so ignore it?

@@ -76,29 +83,30 @@ function GridColumnMenuAggregationItem(props: GridColumnMenuItemProps) {
<ListItemText>
<FormControl size="small" fullWidth sx={{ minWidth: 150 }}>
<InputLabel id={`${id}-label`}>{label}</InputLabel>
<Select
<rootProps.slots.baseSelect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel';
import { unstable_useId as useId } from '@mui/utils';
import Select, { SelectChangeEvent } from '@mui/material/Select';
import { SelectChangeEvent } from '@mui/material/Select';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace SelectChangeEvent with { target: { value: string } } to avoid imports from @mui/material/Select?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why I kept it here is, I thought most transpilers strip off type imports on production builds, due to which it should be OK to use types from these packages, am I missing something here?

Copy link
Member

@oliviertassinari oliviertassinari May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the point Andrew raised is that this import will fail once we make @mui/material an optional peer dependency. I think it can be solved later on.

Copy link
Member Author

@MBilalShafi MBilalShafi Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, let's remove it then

@@ -18,6 +18,22 @@ import {
import { gridAggregationModelSelector } from '../hooks/features/aggregation/gridAggregationSelectors';
import { GridAggregationModel } from '../hooks/features/aggregation/gridAggregationInterfaces';

const MenuItem = styled(MUIMenuItem)(() => ({
'&:hover': {
Copy link
Member

@oliviertassinari oliviertassinari May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pointer cursor feels strange, it signals that I can click but clicking doesn't do anything:

Screen.Recording.2023-05-31.at.15.29.43.mov

So either:

Suggested change
'&:hover': {
cursor: 'default',
'&:hover': {

or we wire the click to focus the select and open it.


Off-topic. The MenuItem component might need a mode where it's only here to handle consistent spacing but not have any actions.

Copy link
Member Author

@MBilalShafi MBilalShafi Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a default cursor.

The MenuItem component might need a mode where it's only here to handle consistent spacing but not have any actions.

Yes, I guess that could be a useful mode to handle more use-cases like this.

import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel';
import { unstable_useId as useId } from '@mui/utils';
import Select, { SelectChangeEvent } from '@mui/material/Select';
import { SelectChangeEvent } from '@mui/material/Select';
Copy link
Member

@oliviertassinari oliviertassinari May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the point Andrew raised is that this import will fail once we make @mui/material an optional peer dependency. I think it can be solved later on.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow-up on my feedback in #6619!

@@ -9,7 +9,9 @@ import { GridColumnMenuContainerProps } from './GridColumnMenuProps';
import { gridClasses } from '../../../constants/gridClasses';

const StyledMenuList = styled(MenuList)(() => ({
minWidth: 248,
'@media (pointer: fine)': {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that the constraint is on whether the primary pointer is fine (e.g. cursor) or not (e.g. touch screen). It feels like it's more a problem with screen width, so

Suggested change
'@media (pointer: fine)': {
[theme.breakpoints.up('sm')]: {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I think the same is done in MUI MenuList.

Comment on lines 117 to 121
{selectedAggregationRule ? (
<rootProps.slots.baseIconButton onClick={handleAggregationItemChange}>
<rootProps.slots.columnMenuClearIcon fontSize="small" color="action" />
</rootProps.slots.baseIconButton>
) : null}
Copy link
Member

@oliviertassinari oliviertassinari May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the clear icon be part of the text field? It sounds more like an external element, it's rendered outside of the input.

Screenshot 2023-05-31 at 15 49 25

Off-topic. I wonder if we wouldn't want to move toward removing baseFormControl, baseInputLabel, baseSelect as a slot. This concept feels MUI-centered, not something that translates often to custom design systems that developers might want to customize the data grid with. Instead, we could replace them with an input and select slots (not sure, but could).

Copy link
Member Author

@MBilalShafi MBilalShafi Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, making it part of the text field would make it feel a bit better. endAdornment worked but by default it collided with the dropdown icon, so I had to add a margin, is it a known bug with MUI select? 🤔
image

I wonder if we wouldn't want to move toward removing baseFormControl, baseInputLabel, baseSelect as a slot. This concept feels MUI-centered, not something that translates often to custom design systems that developers might want to customize the data grid with. Instead, we could replace them with an input and select slots (not sure, but could).

Do you mean native input/select components? I feel currently we are going in the other direction, by adding slots for all possible components for them to be able to be swapped between Material/Joy UI/any future design system's components. I can't picture how a developer will add their custom design system on top if we replace these items with the native input/select.
Or the point is to make it custom-interface-free (support the native props only) so that it's compatible with most users' use cases?

@oliviertassinari oliviertassinari added design This is about UI or UX design, please involve a designer and removed design: ux labels Aug 18, 2023
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 12, 2023
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@MBilalShafi MBilalShafi changed the base branch from master to v6.x March 21, 2024 02:43
@MBilalShafi
Copy link
Member Author

It has been diverged a bit. Will reopen from recent commits.

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! design This is about UI or UX design, please involve a designer PR: out-of-date The pull request has merge conflicts and can't be merged v6.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants