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

[docs] Bring back *Component and *Props codemods and deprecation messages #44383

Merged
merged 4 commits into from
Nov 15, 2024

Conversation

DiegoAndai
Copy link
Member

@DiegoAndai DiegoAndai commented Nov 11, 2024

In #42466, we reverted these codemods and deprecation messages as we weren't sure of the direction of the slot pattern. Now that we're continuing this effort, we're bringing the deprecation messages back.

This PR also modifies Autocomplete's ListboxComponent deprecation and codemods to point to slotProps.listbox.component instead of slots.listbox, which is the correct migration path.

@DiegoAndai DiegoAndai added docs Improvements or additions to the documentation package: material-ui Specific to @mui/material labels Nov 11, 2024
@DiegoAndai DiegoAndai self-assigned this Nov 11, 2024
@mui-bot
Copy link

mui-bot commented Nov 11, 2024

@DiegoAndai DiegoAndai changed the title [docs][material-ui] Bring back *Component and *Props deprecation messages [docs][material-ui] Bring back *Component and *Props codemods and deprecation messages Nov 11, 2024
@sai6855
Copy link
Contributor

sai6855 commented Nov 12, 2024

Now that we're continuing this effort, we're bringing the deprecation messages back.

There are few PR's which were closed due to unsure of direction, do you think they can be reopened?

@mnajdova
Copy link
Member

There are few PR's which were closed due to unsure of direction, do you think they can be reopened?

Yep, we can re-open them if the contributor are still interested in continuing the effort.

@@ -87,6 +87,36 @@ You can also manually update your theme as shown in the snippet below:

This reduces the API surface and lets you define variants in other slots of the component.

## Accordion
Copy link
Member

Choose a reason for hiding this comment

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

This page could become confusing. If we plan to continue to add these sections here, we should include the version in which the new API was introduced. Otherwise people may run the codemod while installing an older version (e.g. 6.0.0).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look into how to do this

Copy link
Member Author

Choose a reason for hiding this comment

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

@mnajdova what do you think about this approach:

  • For APIs introduced in 6.0.0, we don't add any callout
  • For APIs introduced after 6.0.0, we add a warning callout specifying the version in which the API was added

If you agree, this PR doesn't need any change, as these APIs were introduced in 6.0.0. The deprecation messages were omitted while we discussed the direction of the slot pattern, which is why we are bringing them back now.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, ok I see, I thought the APIs were introduced later.

@oliviertassinari oliviertassinari changed the title [docs][material-ui] Bring back *Component and *Props codemods and deprecation messages [docs] Bring back *Component and *Props codemods and deprecation messages Nov 15, 2024
@DiegoAndai DiegoAndai merged commit a0ffee4 into mui:master Nov 15, 2024
22 checks passed
@DiegoAndai DiegoAndai deleted the bring-back-deprecations branch November 15, 2024 17:59
@oliviertassinari oliviertassinari added package: material-ui Specific to @mui/material and removed package: material-ui Specific to @mui/material labels Nov 15, 2024
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.

I was worried when seeing all the complexity in the useSlot() hooks implementation, so I went I checked the performance of the Autocomplete after #41875 (also introduced so many regressions that I got suspicious about it being the right API, is it a foot gun).

The results:

v4.12.4 oliviertassinari@354cd19
noop (baseline):
02.56 ±00.30ms
Grid (html):
66.07 ±07.55ms ⬅️

v5.0.0
? didn't test

v6.0.0-alpha.6, v6.0.0-alpha.7, v6.1.7, all around
noop (baseline):
02.59 ±00.31ms
Grid (html):
135.15 ±07.87ms ⬅️

So no noticeable difference, it looks like pushing further with the slots prop API is the right move (and continue to find ways to simplify that logic). Even with a compound component ejection, this is likely still needed. I guess it's really JSS -> Emotion that was a major performance regression. cc @romgrk for the fun fact.

Comment on lines +290 to +301
- PaperComponent={CustomPaperComponent}
- PopperComponent={CustomPopperComponent}
- ListboxComponent={CustomListboxComponent}
+ slots={{
+ paper: CustomPaperComponent,
+ popper: CustomPopperComponent,
+ }}
+ slotProps={{
+ listbox: {
+ component: CustomListboxComponent,
+ },
+ }}
Copy link
Member

@oliviertassinari oliviertassinari Nov 15, 2024

Choose a reason for hiding this comment

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

Correct spacing coding style

Suggested change
- PaperComponent={CustomPaperComponent}
- PopperComponent={CustomPopperComponent}
- ListboxComponent={CustomListboxComponent}
+ slots={{
+ paper: CustomPaperComponent,
+ popper: CustomPopperComponent,
+ }}
+ slotProps={{
+ listbox: {
+ component: CustomListboxComponent,
+ },
+ }}
- PaperComponent={CustomPaperComponent}
- PopperComponent={CustomPopperComponent}
- ListboxComponent={CustomListboxComponent}
+ slots={{
+ paper: CustomPaperComponent,
+ popper: CustomPopperComponent,
+ }}
+ slotProps={{
+ listbox: {
+ component: CustomListboxComponent,
+ },
+ }}

Comment on lines +316 to +321
- ChipProps={CustomChipProps}
- ListboxProps={CustomListboxProps}
+ slotProps={{
+ chip: CustomChipProps,
+ listbox: CustomListboxProps,
+ }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- ChipProps={CustomChipProps}
- ListboxProps={CustomListboxProps}
+ slotProps={{
+ chip: CustomChipProps,
+ listbox: CustomListboxProps,
+ }}
- ChipProps={CustomChipProps}
- ListboxProps={CustomListboxProps}
+ slotProps={{
+ chip: CustomChipProps,
+ listbox: CustomListboxProps,
+ }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants