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

[Popover] Fix onEntering event propagation #13821

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/material-ui/src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce
import EventListener from 'react-event-listener';
import ownerDocument from '../utils/ownerDocument';
import ownerWindow from '../utils/ownerWindow';
import { createChainedFunction } from '../utils/helpers';
import withStyles from '../styles/withStyles';
import Modal from '../Modal';
import Grow from '../Grow';
Expand Down Expand Up @@ -300,7 +301,7 @@ class Popover extends React.Component {
transformOrigin,
TransitionComponent,
transitionDuration: transitionDurationProp,
TransitionProps,
TransitionProps = {},
...other
} = this.props;

Expand Down Expand Up @@ -329,13 +330,13 @@ class Popover extends React.Component {
in={open}
onEnter={onEnter}
onEntered={onEntered}
onEntering={this.handleEntering}
onExit={onExit}
onExited={onExited}
onExiting={onExiting}
role={role}
timeout={transitionDuration}
{...TransitionProps}
onEntering={createChainedFunction(this.handleEntering, TransitionProps.onEntering)}
>
<Paper
className={classes.paper}
Expand Down
16 changes: 16 additions & 0 deletions packages/material-ui/src/Popover/Popover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,4 +845,20 @@ describe('<Popover />', () => {
assert.strictEqual(wrapper.find(TransitionComponent).props().timeout, undefined);
});
});

describe('prop: TransitionProp', () => {
it('should fire Popover transition event callbacks', () => {
const handler1 = spy();
const handler2 = spy();
const wrapper = shallow(
<Popover {...defaultProps} TransitionProps={{ onEntering: handler2 }} onEntering={handler1}>
<div />
</Popover>,
);

wrapper.find(Grow).simulate('entering', { style: {} });
assert.strictEqual(handler1.callCount, 1);
assert.strictEqual(handler2.callCount, 1);
});
});
});