material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[material-ui][Typography] Enforce responsive typography type checking in sx prop

Open Sergio16T opened this issue 1 year ago • 6 comments

Fixes #42918

Typography Prop Extended to Enforce Typography Breakpoint Types.

Sergio16T avatar Jul 15 '24 18:07 Sergio16T

Netlify deploy preview

https://deploy-preview-42945--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad) No bundle size changes

Generated by :no_entry_sign: dangerJS against 556ce79ca9f5f06168173324fc841f34a1b7b5c4

mui-bot avatar Jul 15 '24 18:07 mui-bot

Reviewed CI build step failure and am working to resolve.

Sergio16T avatar Jul 15 '24 18:07 Sergio16T

Addressed many of CI failures. Could use an assist with understanding why the test_static is failing with the following prompt: pnpm proptypes` changes committed? I ran pnpm proptypes && pnpm docs:api to generate changes and committed.

Sergio16T avatar Jul 15 '24 20:07 Sergio16T

@ZeeshanTamboli Thank you for the feedback on the PR! Makes sense about omitting the sx prop to reduce the scope of changes. And the same for @typescript-to-proptypes-ignore to disable the proptype generation in favor of PropTypes.object. 🚀

Sergio16T avatar Jul 16 '24 08:07 Sergio16T

@ZeeshanTamboli, @DiegoAndai, @siriwatknp Commenting to keep this PR active. Awaiting final review.

Sergio16T avatar Aug 02 '24 04:08 Sergio16T

@ZeeshanTamboli, @DiegoAndai, @siriwatknp Commenting to keep this PR active. Awaiting final review.

Upon reflection, I believe this is a breaking change. If users extend TypographyProps in their custom components, they must also omit the sx prop if it's defined in their custom component. That would seem like a edge case though. It looks good to me, and I've already requested reviews from others.

ZeeshanTamboli avatar Aug 02 '24 06:08 ZeeshanTamboli

@DiegoAndai @siriwatknp Just a reminder to review this PR.

ZeeshanTamboli avatar Sep 19 '24 14:09 ZeeshanTamboli

Hey @Sergio16T and @goodwin64, I'm sorry for the delay in responding to this PR. It's been an intense couple of months with the v6 release 😅.

Let me know if I understand correctly: the intent of https://github.com/mui/material-ui/issues/42918 is for users to be able to restraint the typography type? So it won't accept any other values that are not the variants?

If so, I don't think this should be changed in the component level but rather the SxProps level, as it should work on all components in the same way

What do you think @siriwatknp? I'm not familiar with how the typography sx property is implemented, may I ask you to provide your insight into how it works?

DiegoAndai avatar Oct 04 '24 18:10 DiegoAndai

While this fixes the typography but it creates more complexity to the codebase. What's about other fields? I'm pretty sure there will be more requests once this is merged.

The underlying problem is the type of sx prop, not specifically typography. It cannot be enforced to the responsive type because sx prop has to support any CSS selector which is a string.

The best experience I can achieve so far is with autocomplete for the typography but not possible to enforce the responsive keys due to https://github.com/mui/material-ui/blob/master/packages/mui-system/src/styleFunctionSx/styleFunctionSx.d.ts#L64

I put on hold to this PR until we can figure out a better solution for the whole sx type system. cc @Janpot

siriwatknp avatar Oct 07 '24 04:10 siriwatknp