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

Box element does not have component prop anymore even when used directly as an elemtent. #44622

Closed
1 task done
mtajammulzia opened this issue Dec 1, 2024 · 1 comment
Closed
1 task done
Assignees
Labels
component: Box The React component. duplicate This issue or pull request already exists

Comments

@mtajammulzia
Copy link

mtajammulzia commented Dec 1, 2024

Search keywords

Box, BoxProps

Latest version

  • I have tested the latest version

Steps to reproduce

Steps:

  1. Setup a next app with create next-app
  2. Install MUI dependencies as mentioned on the installation page
  3. Try using Box component as following
<Box component="span">
 ...
</Box>

OR

Check type of BoxProps

Current behavior

As mentioned on this Changelog component prop was removed from BoxProps type as Box already has it and that we can use it when we are using it as Styled component like mentioned in the change log. This restricts using component as prop even when we use Box directly as an element.

Expected behavior

When using Box as element, we should be able to pass component prop.

Context

Rather than having to use type casting and using styled, users should be able to pass component prop when using Box directly as an element.

For reference, Stack type is as follows:

export type StackProps<
  RootComponent extends React.ElementType = StackTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<StackTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
  component?: React.ElementType;
};

While Box type is as follows:

export type BoxProps<
  RootComponent extends React.ElementType = BoxTypeMap['defaultComponent'],
  AdditionalProps = {},
> = OverrideProps<BoxTypeMap<AdditionalProps, RootComponent, MaterialTheme>, RootComponent>;

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@mtajammulzia mtajammulzia added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 1, 2024
@zannager zannager added the component: Box The React component. label Dec 2, 2024
@DiegoAndai
Copy link
Member

Hey @mtajammulzia, thanks for the report.

This is a duplicate of #43955, so I'm closing in favor of that issue where you can follow the progress.

There's already a PR to fix this: #44643.

@DiegoAndai DiegoAndai closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@DiegoAndai DiegoAndai added duplicate This issue or pull request already exists and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Box The React component. duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants