From 14441c8860f2667f9700648bc6697d2a9b666a1a Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Fri, 2 Dec 2016 06:47:00 -0600 Subject: [PATCH] [IconMenu] Fix controlled IconMenus to honor onRequestChange (#5704) --- src/IconMenu/IconMenu.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/IconMenu/IconMenu.js b/src/IconMenu/IconMenu.js index ca34b8d87567e8..11580f57be5473 100644 --- a/src/IconMenu/IconMenu.js +++ b/src/IconMenu/IconMenu.js @@ -179,16 +179,16 @@ class IconMenu extends Component { if (this.props.open !== null) { this.props.onRequestChange(false, reason); + } else { + this.setState({open: false}, () => { + // Set focus on the icon button when the menu close + if (isKeyboard) { + const iconButton = this.refs.iconButton; + ReactDOM.findDOMNode(iconButton).focus(); + iconButton.setKeyboardFocus(); + } + }); } - - this.setState({open: false}, () => { - // Set focus on the icon button when the menu close - if (isKeyboard) { - const iconButton = this.refs.iconButton; - ReactDOM.findDOMNode(iconButton).focus(); - iconButton.setKeyboardFocus(); - } - }); } open(reason, event) {