Skip to content

Commit

Permalink
Merge remote-tracking branch 'call_em_all_-_master/master'
Browse files Browse the repository at this point in the history
* call_em_all_-_master/master:
  [showcase] added showcase of 'HoopHubs.com' (mui#7677)
  [PopOver] Fixed bug where PopOver renders relative to screen rather than layout container in React Fiber (mui#7663)
  • Loading branch information
djbuckley committed Aug 7, 2017
2 parents c72d77a + b54b6c6 commit 8bcd68b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/discover-more/Showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ const appList = [
img: 'images/showcase/brainbok-for-pmp-capm-certification.png',
link: 'https://www.brainbok.com',
},
{
title: 'HoopHubs篮圈 - 查CBA/NBA比赛数据,就上HoopHubs篮圈',
author: 'HoopHubs',
img: 'images/showcase/hoophubs-basketball-stats-tool.png',
link: 'http://www.hoophubs.com',
},
];

const Showcase = () => (
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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('touchTap');
wrapper.find('.item1').simulate('click');
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('touchTap');
wrapper.find('.item2').simulate('click');
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: 13 additions & 5 deletions src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ 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,
Expand All @@ -156,7 +158,7 @@ class Popover extends Component {
}

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

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

componentDidUpdate() {
this.setPlacement();
clearTimeout(this.placementTimeout);
this.placementTimeout = setTimeout(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 @@ -342,11 +350,11 @@ class Popover extends Component {
return;
}

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

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

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

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

0 comments on commit 8bcd68b

Please sign in to comment.