Skip to content

Commit

Permalink
[Popover] Fix default value
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 5, 2018
1 parent ab3bc94 commit cda700c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/material-ui/src/Collapse/Collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ Collapse.defaultProps = {
timeout: duration.standard,
};

Collapse.muiSupportAuto = true;

export default withStyles(styles, {
withTheme: true,
name: 'MuiCollapse',
Expand Down
2 changes: 2 additions & 0 deletions packages/material-ui/src/Grow/Grow.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,6 @@ Grow.defaultProps = {
timeout: 'auto',
};

Grow.muiSupportAuto = true;

export default withTheme()(Grow);
8 changes: 7 additions & 1 deletion packages/material-ui/src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,17 @@ class Popover extends React.Component {
role,
transformOrigin,
TransitionComponent,
transitionDuration,
transitionDuration: transitionDurationProp,
TransitionProps,
...other
} = this.props;

let transitionDuration = transitionDurationProp;

if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
transitionDuration = undefined;
}

// If the container prop is provided, use that
// If the anchorEl prop is provided, use its parent body element as the container
// If neither are provided let the Modal take care of choosing the container
Expand Down
21 changes: 21 additions & 0 deletions packages/material-ui/src/Popover/Popover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,25 @@ describe('<Popover />', () => {
popoverActions.updatePosition();
});
});

describe('prop: transitionDuration', () => {
it('should apply the auto property if supported', () => {
const wrapper = shallow(
<Popover {...defaultProps}>
<div />
</Popover>,
);
assert.strictEqual(wrapper.find(Grow).props().timeout, 'auto');
});

it('should not apply the auto property if not supported', () => {
const TransitionComponent = props => <div {...props} />;
const wrapper = shallow(
<Popover {...defaultProps} TransitionComponent={TransitionComponent}>
<div />
</Popover>,
);
assert.strictEqual(wrapper.find(TransitionComponent).props().timeout, undefined);
});
});
});
8 changes: 7 additions & 1 deletion packages/material-ui/src/StepContent/StepContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function StepContent(props) {
optional,
orientation,
TransitionComponent,
transitionDuration,
transitionDuration: transitionDurationProp,
TransitionProps,
...other
} = props;
Expand All @@ -43,6 +43,12 @@ function StepContent(props) {
'Material-UI: <StepContent /> is only designed for use with the vertical stepper.',
);

let transitionDuration = transitionDurationProp;

if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
transitionDuration = undefined;
}

return (
<div className={classNames(classes.root, { [classes.last]: last }, className)} {...other}>
<TransitionComponent
Expand Down

0 comments on commit cda700c

Please sign in to comment.