Skip to content

Commit

Permalink
Close any open context menu upon window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
bregenspan committed Apr 7, 2019
1 parent a8fa407 commit 64fdb24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/components/ModulesTreemap.jsx
Expand Up @@ -109,7 +109,8 @@ export default class ModulesTreemap extends Component {
weightProp={store.activeSize}
onMouseLeave={this.handleMouseLeaveTreemap}
onGroupHover={this.handleTreemapGroupHover}
onGroupSecondaryClick={this.handleTreemapGroupSecondaryClick}/>
onGroupSecondaryClick={this.handleTreemapGroupSecondaryClick}
onResize={this.handleResize}/>
<Tooltip visible={showTooltip}>
{tooltipContent}
</Tooltip>
Expand Down Expand Up @@ -202,6 +203,16 @@ export default class ModulesTreemap extends Component {
});
}

handleResize = () => {
// Close any open context menu when the report is resized,
// so it doesn't show in an incorrect position
if (this.state.showChunkContextMenu) {
this.setState({
showChunkContextMenu: false
});
}
}

handleSidebarToggle = () => {
if (this.state.sidebarPinned) {
setTimeout(() => this.treemap.resize());
Expand Down
5 changes: 5 additions & 0 deletions client/components/Treemap.jsx
Expand Up @@ -149,7 +149,12 @@ export default class Treemap extends Component {
}

resize = () => {
const {props} = this;
this.treemap.resize();

if (props.onResize) {
props.onResize();
}
}
}

Expand Down

0 comments on commit 64fdb24

Please sign in to comment.