Skip to content

Commit

Permalink
[core] Revert strict mode compatible transition components
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jun 24, 2019
1 parent 0bee9a7 commit 985ca67
Show file tree
Hide file tree
Showing 77 changed files with 134 additions and 125 deletions.
2 changes: 1 addition & 1 deletion packages/material-ui-lab/src/SpeedDial/SpeedDial.test.js
Expand Up @@ -30,7 +30,7 @@ describe('<SpeedDial />', () => {
}

before(() => {
// StrictModeViolation: uses #simulate
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(
<SpeedDial {...defaultProps} icon={icon}>
Expand Down
Expand Up @@ -17,7 +17,7 @@ describe('<SpeedDialAction />', () => {
};

before(() => {
// StrictModeViolation: uses #simulate
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(<SpeedDialAction {...defaultProps} />);
});
Expand Down
Expand Up @@ -17,7 +17,7 @@ describe('<ToggleButton />', () => {
let classes;

before(() => {
// StrictModeViolation: uses #simulate
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
render = createRender();
classes = getClasses(<ToggleButton value="classes">Hello World</ToggleButton>);
Expand Down
Expand Up @@ -11,7 +11,8 @@ describe('<ToggleButtonGroup />', () => {
let classes;

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(
<ToggleButtonGroup>
<ToggleButton value="hello" />
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/package.json
Expand Up @@ -38,7 +38,6 @@
},
"dependencies": {
"@babel/runtime": "^7.2.0",
"@material-ui/react-transition-group": "^4.2.0",
"@material-ui/styles": "^4.1.2",
"@material-ui/system": "^4.3.0",
"@material-ui/types": "^4.1.1",
Expand All @@ -54,6 +53,7 @@
"popper.js": "^1.14.1",
"prop-types": "^15.7.2",
"react-event-listener": "^0.6.6",
"react-transition-group": "^4.0.0",
"warning": "^4.0.1"
},
"sideEffects": false,
Expand Down
14 changes: 12 additions & 2 deletions packages/material-ui/src/Backdrop/Backdrop.test.js
@@ -1,14 +1,18 @@
import React from 'react';
import { createMount, getClasses } from '@material-ui/core/test-utils';
import { assert } from 'chai';
import { createMount, createShallow, getClasses } from '@material-ui/core/test-utils';
import describeConformance from '../test-utils/describeConformance';
import Backdrop from './Backdrop';

describe('<Backdrop />', () => {
let mount;
let shallow;
let classes;

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses Fade
mount = createMount({ strict: false });
shallow = createShallow({ dive: true });
classes = getClasses(<Backdrop open />);
});

Expand All @@ -23,4 +27,10 @@ describe('<Backdrop />', () => {
refInstanceof: window.HTMLDivElement,
skip: ['componentProp'],
}));

it('should render a backdrop div', () => {
const wrapper = shallow(<Backdrop open className="woofBackdrop" />);
assert.strictEqual(wrapper.childAt(0).hasClass('woofBackdrop'), true);
assert.strictEqual(wrapper.childAt(0).hasClass(classes.root), true);
});
});
Expand Up @@ -20,7 +20,8 @@ describe('<BottomNavigation />', () => {
<BottomNavigationAction icon={icon} />
</BottomNavigation>,
);
mount = createMount({ strict: true });
// StrictModeViolation: uses BottomNavigationAction
mount = createMount({ strict: false });
});

after(() => {
Expand Down
Expand Up @@ -13,7 +13,7 @@ describe('<BottomNavigationAction />', () => {
const icon = <Icon>restore</Icon>;

before(() => {
// StrictModeViolation: uses #StrictMode
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(<BottomNavigationAction />);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ButtonBase/ButtonBase.test.js
Expand Up @@ -29,7 +29,7 @@ describe('<ButtonBase />', () => {

before(() => {
shallow = createShallow({ dive: true, disableLifecycleMethods: true });
// StrictModeViolation: uses simulate
// StrictModeViolation: uses TouchRipple
mount = createMount({ strict: false });
classes = getClasses(<ButtonBase />);
});
Expand Down
13 changes: 3 additions & 10 deletions packages/material-ui/src/ButtonBase/Ripple.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';

/**
* @ignore - internal component.
Expand Down Expand Up @@ -40,16 +40,9 @@ function Ripple(props) {
[classes.childPulsate]: pulsate,
});

const rippleRef = React.useRef();

return (
<Transition
onEnter={handleEnter}
onExit={handleExit}
{...other}
findDOMNode={() => rippleRef.current}
>
<span className={rippleClassName} ref={rippleRef} style={rippleStyles}>
<Transition onEnter={handleEnter} onExit={handleExit} {...other}>
<span className={rippleClassName} style={rippleStyles}>
<span className={childClassName} />
</span>
</Transition>
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ButtonBase/TouchRipple.js
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { TransitionGroup } from '@material-ui/react-transition-group';
import { TransitionGroup } from 'react-transition-group';
import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import Ripple from './Ripple';
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Checkbox/Checkbox.test.js
Expand Up @@ -11,7 +11,8 @@ describe('<Checkbox />', () => {

before(() => {
classes = getClasses(<Checkbox />);
mount = createMount({ strict: true });
// StrictModeViolation: uses IconButton
mount = createMount({ strict: false });
});

after(() => {
Expand Down
9 changes: 2 additions & 7 deletions packages/material-ui/src/Collapse/Collapse.js
@@ -1,11 +1,10 @@
import React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';
import withStyles from '../styles/withStyles';
import { duration } from '../styles/transitions';
import { getTransitionProps } from '../transitions/utils';
import { useForkRef } from '../utils/reactHelpers';

export const styles = theme => ({
/* Styles applied to the container element. */
Expand Down Expand Up @@ -150,9 +149,6 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
}
};

const ownRef = React.useRef();
const handleRef = useForkRef(ownRef, ref);

return (
<Transition
in={inProp}
Expand All @@ -164,7 +160,6 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
addEndListener={addEndListener}
timeout={timeout === 'auto' ? null : timeout}
{...other}
findDOMNode={() => ownRef.current}
>
{(state, childProps) => (
<Component
Expand All @@ -180,7 +175,7 @@ const Collapse = React.forwardRef(function Collapse(props, ref) {
minHeight: collapsedHeight,
...style,
}}
ref={handleRef}
ref={ref}
{...childProps}
>
<div className={classes.wrapper} ref={wrapperRef}>
Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui/src/Collapse/Collapse.test.js
Expand Up @@ -5,7 +5,7 @@ import { createMount, getClasses } from '@material-ui/core/test-utils';
import describeConformance from '../test-utils/describeConformance';
import Collapse from './Collapse';
import { createMuiTheme } from '@material-ui/core/styles';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';

describe('<Collapse />', () => {
let mount;
Expand All @@ -16,7 +16,8 @@ describe('<Collapse />', () => {
};

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses react-transition-group
mount = createMount({ strict: false });
classes = getClasses(<Collapse {...defaultProps} />);
});

Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Dialog/Dialog.test.js
Expand Up @@ -26,7 +26,8 @@ describe('<Dialog />', () => {
};

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses Fade
mount = createMount({ strict: false });
classes = getClasses(<Dialog {...defaultProps}>foo</Dialog>);
});

Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Drawer/Drawer.test.js
Expand Up @@ -13,7 +13,8 @@ describe('<Drawer />', () => {
let classes;

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses Slide
mount = createMount({ strict: false });
classes = getClasses(
<Drawer>
<div />
Expand Down
Expand Up @@ -16,7 +16,8 @@ describe('<ExpansionPanel />', () => {
const minimalChildren = [<ExpansionPanelSummary key="header" />];

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses Collapse
mount = createMount({ strict: false });
classes = getClasses(<ExpansionPanel>{minimalChildren}</ExpansionPanel>);
});

Expand Down
Expand Up @@ -15,7 +15,7 @@ describe('<ExpansionPanelSummary />', () => {
}

before(() => {
// StrictModeViolation: uses #simulate
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(<ExpansionPanelSummary />);
});
Expand Down
8 changes: 2 additions & 6 deletions packages/material-ui/src/Fade/Fade.js
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';
import { duration } from '../styles/transitions';
import useTheme from '../styles/useTheme';
import { reflow, getTransitionProps } from '../transitions/utils';
Expand Down Expand Up @@ -35,6 +35,7 @@ const Fade = React.forwardRef(function Fade(props, ref) {
...other
} = props;
const theme = useTheme();
const handleRef = useForkRef(children.ref, ref);

const handleEnter = node => {
reflow(node); // So the animation always start from the start.
Expand Down Expand Up @@ -68,10 +69,6 @@ const Fade = React.forwardRef(function Fade(props, ref) {
}
};

const ownRef = React.useRef();
const userRef = useForkRef(children.ref, ref);
const handleRef = useForkRef(ownRef, userRef);

return (
<Transition
appear
Expand All @@ -80,7 +77,6 @@ const Fade = React.forwardRef(function Fade(props, ref) {
onExit={handleExit}
timeout={timeout}
{...other}
findDOMNode={() => ownRef.current}
>
{(state, childProps) => {
return React.cloneElement(children, {
Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui/src/Fade/Fade.test.js
Expand Up @@ -4,7 +4,7 @@ import { spy, useFakeTimers } from 'sinon';
import { createMount } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
import Fade from './Fade';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';

describe('<Fade />', () => {
let mount;
Expand All @@ -15,7 +15,8 @@ describe('<Fade />', () => {
};

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses react-transition-group
mount = createMount({ strict: false });
});

after(() => {
Expand Down
Expand Up @@ -12,7 +12,8 @@ describe('<FormControlLabel />', () => {
let classes;

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses Checkbox in test
mount = createMount({ strict: false });
classes = getClasses(<FormControlLabel label="Pizza" control={<div />} />);
});

Expand Down
8 changes: 2 additions & 6 deletions packages/material-ui/src/Grow/Grow.js
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Transition } from '@material-ui/react-transition-group';
import { Transition } from 'react-transition-group';
import useTheme from '../styles/useTheme';
import { reflow, getTransitionProps } from '../transitions/utils';
import { useForkRef } from '../utils/reactHelpers';
Expand Down Expand Up @@ -29,6 +29,7 @@ const Grow = React.forwardRef(function Grow(props, ref) {
const { children, in: inProp, onEnter, onExit, style, timeout = 'auto', ...other } = props;
const timer = React.useRef();
const autoTimeout = React.useRef();
const handleRef = useForkRef(children.ref, ref);
const theme = useTheme();

const handleEnter = node => {
Expand Down Expand Up @@ -111,10 +112,6 @@ const Grow = React.forwardRef(function Grow(props, ref) {
};
}, []);

const ownRef = React.useRef();
const userRef = useForkRef(children.ref, ref);
const handleRef = useForkRef(userRef, ownRef);

return (
<Transition
appear
Expand All @@ -124,7 +121,6 @@ const Grow = React.forwardRef(function Grow(props, ref) {
addEndListener={addEndListener}
timeout={timeout === 'auto' ? null : timeout}
{...other}
findDOMNode={() => ownRef.current}
>
{(state, childProps) => {
return React.cloneElement(children, {
Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui/src/Grow/Grow.test.js
Expand Up @@ -5,8 +5,8 @@ import { createMount } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
import Grow from './Grow';
import { createMuiTheme } from '@material-ui/core/styles';
import { Transition } from '@material-ui/react-transition-group';
import { ThemeProvider } from '@material-ui/styles';
import { Transition } from 'react-transition-group';
import { useForkRef } from '../utils/reactHelpers';

describe('<Grow />', () => {
Expand All @@ -17,7 +17,8 @@ describe('<Grow />', () => {
};

before(() => {
mount = createMount({ strict: true });
// StrictModeViolation: uses react-transition-group
mount = createMount({ strict: false });
});

after(() => {
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/IconButton/IconButton.test.js
Expand Up @@ -20,7 +20,8 @@ describe('<IconButton />', () => {

before(() => {
shallow = createShallow({ dive: true });
mount = createMount({ strict: true });
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
classes = getClasses(<IconButton />);
});

Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/ListItem/ListItem.test.js
Expand Up @@ -20,7 +20,8 @@ describe('<ListItem />', () => {

before(() => {
classes = getClasses(<ListItem />);
mount = createMount({ strict: true });
// StrictModeViolation: uses ButtonBase
mount = createMount({ strict: false });
});

after(() => {
Expand Down

0 comments on commit 985ca67

Please sign in to comment.