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] Fix column resize not working with special character #13069
base: master
Are you sure you want to change the base?
Conversation
059ce2f
to
23c6693
Compare
Deploy preview: https://deploy-preview-13069--material-ui-x.netlify.app/ |
packages/x-data-grid/src/hooks/features/columnResize/useGridColumnResize.tsx
Outdated
Show resolved
Hide resolved
@cherniavskii I'll let you approve & merge. |
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.
Thank you!
); | ||
if (headerFilterElement) { | ||
refs.headerFilterElement = headerFilterElement as HTMLDivElement; | ||
} | ||
|
||
refs.groupHeaderElements = findGroupHeaderElementsFromField( | ||
apiRef.current.columnHeadersContainerRef?.current!, | ||
colDef.field, | ||
escapedColDefField, |
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 think that the escaping should happen in findGroupHeaderElementsFromField()
. Otherwise, we will reintroduce the bug the next time the function is used.
Same with findHeaderElementFromField
// HACK: The jsdom test is failing because CSS.escape doesn't exist in that context. | ||
// We have decided that we want to preserve the bug in jsdom | ||
// https://github.com/mui/mui-x/pull/13069#discussion_r1603270444 | ||
const escapedColDefField = typeof CSS === 'undefined' ? colDef.field : CSS.escape(colDef.field); |
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.
This is inconsistent with #2033. To normalize to have one solution for one problem.
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.
Agreed, use the existing escapeOperandAttributeSelector
function instead of CSS.escape
.
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.
Why not standardize on CSS.escape?
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.
There are more selectors to fix, e.g.
- findGridHeader
- findGridCells
c65edbb
to
0ee6603
Compare
Closes: #12954
The support of the CSS API seems common enough: https://caniuse.com/mdn-api_css_escape_static.Before: https://codesandbox.io/p/sandbox/wild-surf-ygtjk6
After: https://codesandbox.io/p/sandbox/upbeat-grass-9h7tfd