Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- As discussed on mui#4393 and mui#4783 I have provided a fix for popover position issue on autocomplete.
  • Loading branch information
Gorkem CINAR committed Jul 19, 2017
1 parent 49023c4 commit fea465e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class Popover extends Component {
* The zDepth of the popover.
*/
zDepth: propTypes.zDepth,

scrollElement : PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
]),
};

static defaultProps = {
Expand Down Expand Up @@ -304,8 +309,8 @@ class Popover extends Component {
targetPosition = this.applyAutoPositionIfNeeded(anchor, target, targetOrigin, anchorOrigin, targetPosition);
}

targetEl.style.top = `${Math.max(0, targetPosition.top)}px`;
targetEl.style.left = `${Math.max(0, targetPosition.left)}px`;
targetEl.style.top = `${targetPosition.top}px`;
targetEl.style.left = `${targetPosition.left}px`;
targetEl.style.maxHeight = `${window.innerHeight}px`;
};

Expand Down Expand Up @@ -395,7 +400,7 @@ class Popover extends Component {
return (
<div style={styles.root}>
<EventListener
target="window"
target={this.props.scrollElement || "window"}
onScroll={this.handleScroll}
onResize={this.handleResize}
/>
Expand Down

0 comments on commit fea465e

Please sign in to comment.