Skip to content

Commit

Permalink
Revert "[PopOver] Fixed bug where PopOver renders relative to screen …
Browse files Browse the repository at this point in the history
…rather than layout container in React Fiber (mui#7663)"

This reverts commit 8432807.
  • Loading branch information
igorokb committed Sep 15, 2017
1 parent eaeb999 commit 5110d4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Menu/Menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ describe('<Menu />', () => {
</Menu>
);

wrapper.find('.item1').simulate('click');
wrapper.find('.item1').simulate('touchTap');
assert.strictEqual(wrapper.state('focusIndex'), 0);
document.body.dispatchEvent(new window.Event('mouseup', {bubbles: true}));
assert.strictEqual(wrapper.state('focusIndex'), -1);

wrapper.find('.item2').simulate('click');
wrapper.find('.item2').simulate('touchTap');
assert.strictEqual(wrapper.state('focusIndex'), 1);
document.body.dispatchEvent(new window.Event('mouseup', {bubbles: true}));
assert.strictEqual(wrapper.state('focusIndex'), 1);
Expand Down
18 changes: 5 additions & 13 deletions src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@ class Popover extends Component {
this.handleResize = throttle(this.setPlacement, 100);
this.handleScroll = throttle(this.setPlacement.bind(this, true), 50);

this.popoverRefs = {};

this.state = {
open: props.open,
closing: false,
};
}

componentDidMount() {
this.placementTimeout = setTimeout(this.setPlacement);
this.setPlacement();
}

componentWillReceiveProps(nextProps) {
Expand Down Expand Up @@ -175,19 +173,13 @@ class Popover extends Component {
}

componentDidUpdate() {
clearTimeout(this.placementTimeout);
this.placementTimeout = setTimeout(this.setPlacement);
this.setPlacement();
}

componentWillUnmount() {
this.handleResize.cancel();
this.handleScroll.cancel();

if (this.placementTimeout) {
clearTimeout(this.placementTimeout);
this.placementTimeout = null;
}

if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
Expand Down Expand Up @@ -293,11 +285,11 @@ class Popover extends Component {
return;
}

if (!this.popoverRefs.layer.getLayer()) {
if (!this.refs.layer.getLayer()) {
return;
}

const targetEl = this.popoverRefs.layer.getLayer().children[0];
const targetEl = this.refs.layer.getLayer().children[0];
if (!targetEl) {
return;
}
Expand Down Expand Up @@ -418,7 +410,7 @@ class Popover extends Component {
onResize={this.handleResize}
/>
<RenderToLayer
ref={(ref) => this.popoverRefs.layer = ref}
ref="layer"
open={this.state.open}
componentClickAway={this.componentClickAway}
useLayerForClickAway={this.props.useLayerForClickAway}
Expand Down
9 changes: 3 additions & 6 deletions src/Popover/Popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ describe('<Popover />', () => {
it('should stop listening correctly', (done) => {
const wrapper = mountWithContext(<Popover open={true} />);

// Ensure layering has been set up correctly before simulation
setTimeout(() => {
wrapper.instance().handleScroll();
wrapper.instance().handleScroll();
wrapper.unmount();
}, 10);
wrapper.instance().handleScroll();
wrapper.instance().handleScroll();
wrapper.unmount();

setTimeout(() => {
// Wait for the end of the throttle. Makes sure we don't crash.
Expand Down

0 comments on commit 5110d4a

Please sign in to comment.