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] Fix column resize not working with special character #13069

Merged
merged 9 commits into from
May 31, 2024

Conversation

oukunan
Copy link
Contributor

@oukunan oukunan commented May 9, 2024

@oukunan oukunan force-pushed the fix-column-resize-special-characters branch from 059ce2f to 23c6693 Compare May 9, 2024 15:52
@oukunan oukunan changed the title [DataGrid] Fix column resize not working with special character Fix column resize not working with special character May 9, 2024
@oukunan oukunan changed the title Fix column resize not working with special character [DataGrid] Fix column resize not working with special character May 9, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label May 10, 2024
@mui-bot
Copy link

mui-bot commented May 10, 2024

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

Generated by 🚫 dangerJS against 729ff0d

@romgrk romgrk requested a review from cherniavskii May 16, 2024 17:14
@romgrk
Copy link
Contributor

romgrk commented May 16, 2024

@cherniavskii I'll let you approve & merge.

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.

Thank you!

@oliviertassinari oliviertassinari changed the title [DataGrid] Fix column resize not working with special character [data grid] Fix column resize not working with special character May 25, 2024
// 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);
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not available in jsdom.

Copy link
Member

@oliviertassinari oliviertassinari May 31, 2024

Choose a reason for hiding this comment

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

Alright, I have added this commit ed3472b as the behavior might not be 100% correct right now looking at https://github.com/mathiasbynens/CSS.escape/blob/master/css.escape.js.

The spec https://drafts.csswg.org/cssom/#the-css.escape()-method

Copy link
Contributor

@romgrk romgrk May 31, 2024

Choose a reason for hiding this comment

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

I did argue we should include a ponyfill for CSS.escape but I was defeated. Read the full discussion here. We did go for the existing escape method here though, which made the whole discussion irrelevant as we already had it in the codebase.

Copy link
Member

@oliviertassinari oliviertassinari Jun 2, 2024

Choose a reason for hiding this comment

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

Right, so from what I understand, there are two distinct discussions:

  1. Using escapeOperandAttributeSelector is incorrect, it should use CSS.escape. But escapeOperandAttributeSelector has been good enough so far, so we continue with is, waiting for the problem to be surfaced. Simpler for now. When will be the right time?
  2. jsdom doesn't support CSS.escape by default. Should the data grid do something about it? The strategy used so far has been to support jsdom with no need for custom setup for developers in Material UI, Base UI, MUI X. e.g. [data grid] Tests fail with: "IntersectionObserver is not defined" after upgrading to x-data-grid v7.3.2 #12983. Should we change this?

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.

There are more selectors to fix, e.g.

  • findGridHeader
  • findGridCells

@oukunan oukunan force-pushed the fix-column-resize-special-characters branch from c65edbb to 0ee6603 Compare May 26, 2024 06:32
@romgrk
Copy link
Contributor

romgrk commented May 29, 2024

@oukunan Could you merge master in this branch? That should fix the tests.

@oukunan oukunan force-pushed the fix-column-resize-special-characters branch from 0ee6603 to 97cb2a0 Compare May 29, 2024 12:44
@oukunan
Copy link
Contributor Author

oukunan commented May 29, 2024

Hello @romgrk, this branch was rebased using master. Could you verify this branch again?

@romgrk romgrk enabled auto-merge (squash) May 30, 2024 08:22
auto-merge was automatically disabled May 30, 2024 09:47

Head branch was pushed to by a user without write access

@oukunan oukunan force-pushed the fix-column-resize-special-characters branch from 78b6894 to 9f91302 Compare May 30, 2024 09:47
@romgrk romgrk merged commit e0cb373 into mui:master May 31, 2024
17 checks passed
@romgrk
Copy link
Contributor

romgrk commented May 31, 2024

Thanks for the PR!

@LukasTy LukasTy changed the title [data grid] Fix column resize not working with special character [DataGrid] Fix column resize not working with special character May 31, 2024
DungTiger pushed a commit to DungTiger/mui-x that referenced this pull request Jul 23, 2024
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Column resize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Column resizing not working with special characters in column names
6 participants