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

[material-ui][ListItemSecondaryAction] Deprecate component

Open aarongarciah opened this issue 9 months ago • 9 comments

We intended to deprecate ListItemSecondaryAction in v5 in favor of the secondaryAction prop in ListItem, but we forgot to do it officially so we can't remove it in v6. This PR adds a new ListItemSecondaryAction deprecation entry in the docs for v6 so we can remove it in v7. See https://github.com/mui/material-ui/pull/26446 for context.

Preview link: https://deploy-preview-42251--material-ui.netlify.app/material-ui/migration/migrating-from-deprecated-apis/#listitemsecondaryaction

image

aarongarciah avatar May 15 '24 15:05 aarongarciah

@siriwatknp some notes:

  • I tried to mark ListItemSecondaryAction as @deprecated using JSDoc but it was picked up as the component description in the docs. Is there a way to mark components as @deprecated in the code? Other deprecated components like Hidden aren't marked either. Screenshot 2024-05-15 at 17 37 32
  • I also thought about marking listItemSecondaryActionClasses and related stuff as @deprecated, but it doesn't make much sense if we don't mark the component as @deprecated.
  • Lastly, is a codemod provided in these scenarios? The codemod could work or not depending on the user's implementation e.g. if they are using <ListItemSecondaryAction> + the ContainerComponent prop in ListItem the codemod can break user's implementation.
  • As of today, there's no way of displaying a component as deprecated in the API pages e.g. Hidden is marked as deprecated in the usage page but not the API page. This is unfortunate because ListItemSecondaryAction doesn't have a dedicated usage page so it's hard for consumers to know it's deprecated unless they visit the Migrating from deprecated APIs page and we also don't mark components as @deprecated in the code.
  • Should we remove ListItemSecondaryAction from the list of APIs in the Lists docs page?

aarongarciah avatar May 15 '24 15:05 aarongarciah

Netlify deploy preview

Bundle size report

No bundle size changes (Toolpad) No bundle size changes

Generated by :no_entry_sign: dangerJS against ae4992cedb50602ec4ca8e78391f2340caf3c361

mui-bot avatar May 15 '24 15:05 mui-bot

I don't have answers for all questions but:

Is a codemod provided in these scenarios?

We can read the user's implementation and try to apply the changes accordingly, but if it would be too difficult to know the correct replacement, then it's better not to have a codemod. If that's the case, we should explain in detail how to adapt.

As of today, there's no way of displaying a component as deprecated in the API pages e.g. Hidden is marked as deprecated in the usage page but not the API page.

We could implement this capability, what do you think @alexfauquette @danilo-leal?

Should we remove ListItemSecondaryAction from the list of APIs in the Lists docs page?

Yes

DiegoAndai avatar May 16 '24 16:05 DiegoAndai

Should we remove ListItemSecondaryAction from the list of APIs in the Lists docs page?

We have a specific rule to validate that every public component is included in at least one docs md page. Removing ListItemSecondaryAction from the Lists page results in this error while building the docs:

Screenshot 2024-05-16 at 18 28 59

aarongarciah avatar May 16 '24 16:05 aarongarciah

The rendering part you're looking to modify is here:

https://github.com/mui/material-ui/blob/df6516ea9bd7a1377c59dda667ee907838c9bbf1/docs/src/modules/components/ApiPage.js#L251-L261

The description is generated here: https://github.com/mui/material-ui/blob/df6516ea9bd7a1377c59dda667ee907838c9bbf1/packages/api-docs-builder/ApiBuilders/ComponentApiBuilder.ts#L459

alexfauquette avatar May 16 '24 16:05 alexfauquette

We have a specific rule to validate that every public component is included in at least one docs md page. Removing ListItemSecondaryAction from the Lists page results in this error while building the docs:

Could we add a "skip" list so we can skip some of them?

DiegoAndai avatar May 16 '24 16:05 DiegoAndai

Could we add a "skip" list so we can skip some of them?

Another option could be to keep it in the APIs but indicate it is deprecated

image

alexfauquette avatar May 16 '24 16:05 alexfauquette

I think we should look into being able to mark components as @deprecated in JSDoc without it ending up in the component docs description so we can:

  • Automatically display a deprecation callout in the usage and API pages.
  • Remove the entry (or display as deprecated) in the related APIs list.
  • Make any other automation we can think of.

Also, consumers would see components as deprecated in their IDE, which is not the case at the moment afaik.

But probably in another PR. I'm lacking quite some context on how docs are built so tell me if this is not a good idea.

aarongarciah avatar May 16 '24 17:05 aarongarciah

I opened a draft PR with a potential approach we could use to treat JSDoc comments as the source of truth for deprecations: https://github.com/mui/material-ui/pull/42280

aarongarciah avatar May 17 '24 16:05 aarongarciah