-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-16445--material-ui-x.netlify.app/ |
checked={columnVisibilityModel[column.field] !== false} | ||
onClick={toggleColumn} | ||
name={column.field} | ||
style={{ padding: 0.5 }} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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?
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
}; | ||
style?: React.CSSProperties; | ||
tabIndex?: number; | ||
touchRippleRef?: any; // FIXME(v8:romgrk): find a way to remove |
There was a problem hiding this comment.
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?
mui-x/packages/x-data-grid/src/components/columnSelection/GridCellCheckboxRenderer.tsx
Lines 72 to 80 in 5ed0b65
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]); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 }} |
There was a problem hiding this comment.
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?
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.