From 120979556f12d1a5f6f4d75a93851623c040b5f0 Mon Sep 17 00:00:00 2001 From: Ben Callaway Date: Thu, 10 Mar 2016 21:09:56 -0800 Subject: [PATCH] [AutoComplete] Fix openOnFocus behavior AutoComplete will close the child Popover element when requested (e.g. after clicking away from the Popover) only when the child TextField is not in focus. Resolves #callemall/material-ui/3381 --- src/auto-complete.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/auto-complete.jsx b/src/auto-complete.jsx index c7bacc8ede0590..7525621ff08a33 100644 --- a/src/auto-complete.jsx +++ b/src/auto-complete.jsx @@ -390,6 +390,12 @@ const AutoComplete = React.createClass({ } }, + handlePopoverRequestClose() { + if (this.refs.searchTextField && !this.refs.searchTextField.state.isFocused) { + this.close(); + } + }, + blur() { this.refs.searchTextField.blur(); }, @@ -526,7 +532,7 @@ const AutoComplete = React.createClass({ open={open} anchorEl={anchorEl} useLayerForClickAway={false} - onRequestClose={this.close} + onRequestClose={this.handlePopoverRequestClose} animated={animated} > {menu}