Skip to content

Commit

Permalink
[Popper] Fix update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 20, 2018
1 parent ba2ba25 commit 6c83148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/utils/popper/PositionedPopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PositionedPopper extends React.Component {
const { currentTarget } = event;
this.setState(state => ({
anchorEl: currentTarget,
open: !state.placement === placement || !state.open,
open: state.placement !== placement || !state.open,
placement,
}));
};
Expand Down
11 changes: 6 additions & 5 deletions packages/material-ui/src/Popper/Popper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ class Popper extends React.Component {
}

componentDidUpdate(prevProps) {
if (prevProps.open && !this.props.open && !this.props.transition) {
if (prevProps.open !== this.props.open && !this.props.open && !this.props.transition) {
// Otherwise handleExited will call this.
this.handleClose();
}

// Let's update the popper position.
if (
prevProps.open !== this.props.open ||
prevProps.anchorEl !== this.props.anchorEl ||
prevProps.popperOptions !== this.props.popperOptions ||
prevProps.modifiers !== this.props.modifiers ||
Expand Down Expand Up @@ -93,15 +94,15 @@ class Popper extends React.Component {
} = this.props;
const popperNode = ReactDOM.findDOMNode(this);

if (!popperNode || !anchorEl || !open) {
return;
}

if (this.popper) {
this.popper.destroy();
this.popper = null;
}

if (!popperNode || !anchorEl || !open) {
return;
}

this.popper = new PopperJS(getAnchorEl(anchorEl), popperNode, {
placement: flipPlacement(theme, placement),
...popperOptions,
Expand Down

0 comments on commit 6c83148

Please sign in to comment.