Skip to content

Commit

Permalink
[Popper] Fix the transition in the demos (#12194)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 19, 2018
1 parent 77c48ca commit 001c142
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/src/pages/utils/popper/PositionedPopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ const styles = theme => ({
class PositionedPopper extends React.Component {
state = {
anchorEl: null,
open: false,
placement: null,
};

handleClick = placement => event => {
const { currentTarget } = event;
this.setState(state => ({
anchorEl: state.placement === placement && state.anchorEl ? null : currentTarget,
anchorEl: currentTarget,
open: !state.placement === placement || !state.open,
placement,
}));
};

render() {
const { classes } = this.props;
const { anchorEl, placement } = this.state;
const open = Boolean(anchorEl);
const { anchorEl, open, placement } = this.state;

return (
<div className={classes.root}>
Expand Down
7 changes: 4 additions & 3 deletions docs/src/pages/utils/popper/SimplePopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ const styles = theme => ({
class SimplePopper extends React.Component {
state = {
anchorEl: null,
open: false,
};

handleClick = event => {
const { currentTarget } = event;
this.setState(state => ({
anchorEl: state.anchorEl ? null : currentTarget,
anchorEl: currentTarget,
open: !state.open,
}));
};

render() {
const { classes } = this.props;
const { anchorEl } = this.state;
const open = Boolean(anchorEl);
const { anchorEl, open } = this.state;
const id = open ? 'simple-popper' : null;

return (
Expand Down

0 comments on commit 001c142

Please sign in to comment.