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] Refactor: create base Checkbox #16445

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

romgrk
Copy link
Contributor

@romgrk romgrk commented Feb 4, 2025

Part of the design-system agnostic work.

Create the base Checkbox. Unlike the material-ui one, this one handles its own label the same way the base TextField does.

@romgrk romgrk added the component: data grid This is the name of the generic UI component, not the React module! label Feb 4, 2025
@romgrk romgrk requested a review from a team February 4, 2025 02:29
@mui-bot
Copy link

mui-bot commented Feb 4, 2025

Deploy preview: https://deploy-preview-16445--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against b0382f6

checked={columnVisibilityModel[column.field] !== false}
onClick={toggleColumn}
name={column.field}
style={{ padding: 0.5 }}
Copy link
Member

@KenanYusuf KenanYusuf Feb 6, 2025

Choose a reason for hiding this comment

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

When translating padding/margin from sx to style, the value needs to change also— the value was 4px, now it is 0.5px.

Ideally, padding/margin styles should be calculated using the spacing value in the theme, perhaps we should wrap this in a styled to apply the padding?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is an issue with this approach https://app.argos-ci.com/mui/mui-x/builds/30524/135954282

It is applying the padding to the label rather than the checkbox. Not sure how we can target the checkbox here without using Material UI classes 🤔

Copy link
Member

Choose a reason for hiding this comment

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

How about adding density?: 'standard' | 'compact' prop to CheckboxProps and applying padding in BaseCheckbox for 'compact' density?

Copy link

github-actions bot commented Feb 7, 2025

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

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2025
};
style?: React.CSSProperties;
tabIndex?: number;
touchRippleRef?: any; // FIXME(v8:romgrk): find a way to remove
Copy link
Member

Choose a reason for hiding this comment

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

How about moving this part to BaseCheckbox and passing hasFocus prop to it?

React.useEffect(() => {
if (hasFocus) {
const input = checkboxElement.current?.querySelector('input');
input?.focus({ preventScroll: true });
} else if (rippleRef.current) {
// Only available in @mui/material v5.4.1 or later
rippleRef.current.stop({});
}
}, [hasFocus]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that could work. I wonder if autoFocus would be better? It would match the similar prop on MenuList.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if autoFocus would be better?

Yeah, this makes sense 👍🏻

checked={columnVisibilityModel[column.field] !== false}
onClick={toggleColumn}
name={column.field}
style={{ padding: 0.5 }}
Copy link
Member

Choose a reason for hiding this comment

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

How about adding density?: 'standard' | 'compact' prop to CheckboxProps and applying padding in BaseCheckbox for 'compact' density?

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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants