Skip to content

Commit

Permalink
added updatePosition to Popover after table row content updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnb committed Jan 1, 2018
1 parent 533a818 commit baceb9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
12 changes: 0 additions & 12 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ class Example extends React.Component {
["Mason Ray", "Computer Scientist", "San Francisco", 39, "$142,000"]
];

// options: PropTypes.shape({
// sort: PropTypes.bool,
// filter: PropTypes.bool,
// filterType: PropTypes.oneOf(['dropdown', 'checkbox']),
// pagination: PropTypes.bool,
// rowHover: PropTypes.bool,
// rowsPerPage: PropTypes.number,
// rowsPerPageOptions: PropTypes.array,
// search: PropTypes.bool,
// print: PropTypes.bool,
// responsive: PropTypes.bool
// }),

const options = {
filter: true,
Expand Down
4 changes: 3 additions & 1 deletion src/MUIDataTableHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const arrowIcon = {
display: "block",
paddingBottom: "1px",
"& svg": {
width: "100%",
width: "8px",
height: "5px",
verticalAlign: "top",
"& path": {
fillOpacity: 0.35,
},
Expand Down
12 changes: 12 additions & 0 deletions src/MUIPopover/MUIPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ class MUIPopover extends React.Component {
}
}

componentDidUpdate(prevProps, prevState) {
/*
* Update Popover position if a filter removes data from the table because
* it affects the window height which would cause the Popover to in the wrong place
*/
if (this.state.open === true) {
this.anchorEl = findDOMNode(this.anchorEl);
this.popoverActions.updatePosition();
}
}

handleClick = () => {
this.anchorEl = findDOMNode(this.anchorEl);
this.setState({ open: true });
Expand Down Expand Up @@ -84,6 +95,7 @@ class MUIPopover extends React.Component {

const popoverContent = (
<Popover
action={actions => (this.popoverActions = actions)}
key={index}
elevation={2}
open={this.state.open}
Expand Down

0 comments on commit baceb9f

Please sign in to comment.