Skip to content

Commit 6256e2a

Browse files
committed
fix #43 - update opened menu if it is changed while opened
1 parent f6b67a4 commit 6256e2a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Menu.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ export default class Menu extends Component {
3838
}
3939

4040
componentDidUpdate() {
41-
debug('component did update', this._name);
42-
this.context.menuActions._notify();
41+
// force update if menu is opened as its content might have changed
42+
const force = this._isOpen();
43+
debug('component did update', this._name, force);
44+
this.context.menuActions._notify(force);
4345
}
4446

4547
componentWillUnmount() {

src/MenuContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class MenuContext extends Component {
2727
closeMenu: () => this.closeMenu(),
2828
toggleMenu: name => this.toggleMenu(name),
2929
isMenuOpen: () => this.isMenuOpen(),
30-
_notify: () => this._notify()
30+
_notify: force => this._notify(force)
3131
};
3232
const menuRegistry = this._menuRegistry;
3333
return { menuRegistry, menuActions };

0 commit comments

Comments
 (0)