Skip to content

Commit 4aa644b

Browse files
madox2sodik82
authored andcommitted
dont rerender placeholder during menu closing (#68)
* dont rerender placeholder during menu closing * documentation comment
1 parent 3a27d31 commit 4aa644b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/MenuPlaceholder.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export default class MenuPlaceholder extends Component {
99
this.state = {};
1010
}
1111

12+
shouldComponentUpdate() {
13+
// don't terminate closing animation
14+
return !this.props.ctx._isMenuClosing;
15+
}
16+
1217
render() {
1318
const { ctx, backdropStyles } = this.props;
1419
const shouldRenderMenu = ctx.isMenuOpen() && ctx._isInitialized();

src/MenuProvider.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class MenuProvider extends Component {
1919
constructor(props) {
2020
super(props);
2121
this._menuRegistry = makeMenuRegistry();
22+
this._isMenuClosing = false;
2223
}
2324

2425
getChildContext() {
@@ -115,7 +116,15 @@ export default class MenuProvider extends Component {
115116
&& this.optionsRef.close()) || Promise.resolve();
116117
const hideBackdrop = this.backdropRef && this.backdropRef.close();
117118
this._invalidateTriggerLayouts();
118-
return Promise.all([hideMenu, hideBackdrop]);
119+
this._isMenuClosing = true;
120+
return Promise.all([hideMenu, hideBackdrop])
121+
.then(() => {
122+
this._isMenuClosing = false;
123+
})
124+
.catch(err => {
125+
this._isMenuClosing = false;
126+
throw err;
127+
})
119128
}
120129

121130
toggleMenu(name) {

0 commit comments

Comments
 (0)