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

[system] Remove Box clone prop #18496

Closed
2 tasks done
numToStr opened this issue Nov 22, 2019 · 6 comments · Fixed by #26031
Closed
2 tasks done

[system] Remove Box clone prop #18496

numToStr opened this issue Nov 22, 2019 · 6 comments · Fixed by #26031
Labels
breaking change bug 🐛 Something doesn't work component: Box The React component. package: system Specific to @mui/system
Milestone

Comments

@numToStr
Copy link
Contributor

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

clone prop works perfectly fine in development. But when I saw the production build of the app, there styling is ignored which is applied by <Box clone/> component.

Steps to Reproduce 🕹

// BaseRouterLink
import React, { forwardRef } from "react";
import {
    Link as RouterLink,
    LinkProps as RouterLinkProps
} from "react-router-dom";

export default forwardRef<HTMLAnchorElement, RouterLinkProps>((props, ref) => (
    <RouterLink innerRef={ref} {...props} />
));
// <BackButton />
import React, { FC } from "react";
import IconButton, { IconButtonProps } from "@material-ui/core/IconButton";
import BackIcon from "@material-ui/icons/ArrowBackTwoTone";
import BaseRouterLink from "./Base/BaseRouterLink";
import Box from "@material-ui/core/Box";

type Props = IconButtonProps & {
    to: string;
};

const BackButton: FC<Props> = ({ to }) => {
    return (
        <Box clone mb={2}>
            <IconButton component={BaseRouterLink} color="primary" to={to}>
                <BackIcon fontSize="small" />
            </IconButton>
        </Box>
    );
};

export default BackButton;

I attached some images to clarify the scenario with the above components.

Production Build:

margin-bottom is not applied to the button
production

Development Build:

margin-bottom is applied to the button
development

Your Environment 🌎

Tech Version
Material-UI ^4.6.1
React ^16.12.0
Browser Firefox v70
TypeScript ^3.7.2
etc.

I hope component order is not the problem

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 23, 2019

I can't explain it, we won't keep the clone prop long anyway (gone in v5).

@oliviertassinari oliviertassinari added this to the v5 milestone Nov 23, 2019
@numToStr
Copy link
Contributor Author

No big deal for me. I can remove clone prop from my app.

Just asking, why you want to remove it?

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 24, 2019

To avoid issues like this one and to support the system props "everywhere".

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work package: system Specific to @mui/system labels Nov 24, 2019
@numToStr
Copy link
Contributor Author

Oh! I forgot that you guys are planning to include the system api in core. 😊

@oliviertassinari oliviertassinari changed the title [Box] clone prop ingored in production build [system] Box clone prop ignored in production build Oct 20, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 20, 2020

@mnajdova In #22982, I have advocated for removing the clone prop because:

  1. it doesn't longer solve a pain point with the support of the system in the core components (only help with BC)
  2. the injection order is often hard to get right: Box clone not overriding child component styles #15993 (comment) and [system] Remove Box clone prop #18496.

However, I have tried with styled-components and emotion, the injection ordered seemed to be correct, I have no idea how. Do you know? I'm surprised. Should we ask each library's maintainer to make sure this API is reliable and stable going forward?

@oliviertassinari oliviertassinari added the component: Box The React component. label Jan 5, 2021
@oliviertassinari oliviertassinari changed the title [system] Box clone prop ignored in production build [system] Remove Box clone prop Apr 17, 2021
@oliviertassinari
Copy link
Member

Done in #26031 by @m4theushw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change bug 🐛 Something doesn't work component: Box The React component. package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants