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

[Slide] The Slide send direction to children #13906

Closed
2 tasks done
marcelocarmona opened this issue Dec 14, 2018 · 2 comments · Fixed by #13930
Closed
2 tasks done

[Slide] The Slide send direction to children #13906

marcelocarmona opened this issue Dec 14, 2018 · 2 comments · Fixed by #13930
Labels
bug 🐛 Something doesn't work component: transitions This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@marcelocarmona
Copy link

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

I'm not sure if this is a bug or an expected behavior, but Slide sends the prop direction to the children

Current Behavior 😯

image

Steps to Reproduce 🕹

Link: https://codesandbox.io/s/4zlov9w479

  1. Go to the link
  2. Open the console

Your Environment 🌎

Tech Version
Material-UI v3.6.2
React v16.6.3
@oliviertassinari oliviertassinari added the component: slider This is the name of the generic UI component, not the React module! label Dec 15, 2018
@joshwooding
Copy link
Member

@oliviertassinari This isn’t a slider problem, it’s the Transition component Slide

@oliviertassinari oliviertassinari added component: Slide bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. and removed component: slider This is the name of the generic UI component, not the React module! labels Dec 17, 2018
@oliviertassinari
Copy link
Member

@joshwooding Oh by bad, thank you for raising it.
@marcelocarmona It's an issue with our property forwarding logic. react-transition-group forwards all the properties to the child:

return React.cloneElement(child, childProps)

https://github.com/reactjs/react-transition-group/blob/977c9ce44a8b3bc2a04a25f6288b206a2a5812c3/src/Transition.js#L368

I think that it can be fixed like this:

  render() {
    const {
      children,
+     direction,
      onEnter,
      onEntering,
      onExit,
      onExited,
      style: styleProp,
      theme,
      ...other
    } = this.props;

    let style = {};

    // We use this state to handle the server-side rendering.
    // We don't know the width of the children ahead of time.
    // We need to render it.
    if (!this.props.in && !this.mounted) {
      style.visibility = 'hidden';
    }

It was never spotted before because this doesn't raise any warning:

import React from "react";
import ReactDOM from "react-dom";
import { Slide } from "@material-ui/core";

const Foo = (props) => {
  return <div {...props} />
}

function App() {
  return (
    <Slide direction="up" in>
      <Foo />
    </Slide>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Damn, this is a Murphy's law outcome!

Do you want to work on it? :)

@oliviertassinari oliviertassinari added component: transitions This is the name of the generic UI component, not the React module! and removed component: Slide labels Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: transitions This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants