react-z/react-search

Menu doesn't disappear when it loses focus

Closed this issue · 3 comments

Expected behaviour:
With the menu focussed, when the component loses focus, the menu should disappear. Effectively, the autocomplete__menu--hidden should be re-applied to the menu when the component loses focus.

Actual behaviour:
When the menu is focussed and displayed, it won't hide again regardless of losing focus or interacting elsewhere within the DOM.

Steps to reproduce:
Pretty self explanatory really, the official demo exhibits the same behaviour.

More info:
I'm using the latest version 2.0.4 via NPM, within a React 15.4.0 app. Below is the bulk of the React component I've wrapped around react-search.

search(text, cb) {
    SearchActions.searchByString(text, this.state.account.authToken);
    cb(text);
}

select(selection) {
    var result = this.state.results.find(function (result) {
        return result.id == selection[0].id;
    });
    if (result) {
        console.log(result);
        browserHistory.push(result.NodeUrl);
    }
}

render() {
    return (
        <div>
            <Search items={this.state.results}
                    placeholder='Search...'
                    multiple={false}
                    maxSelected={1}
                    getItemsAsync={this.search.bind(this)}
                    onItemsChanged={this.select.bind(this)} />
        </div>
    )
}

I have submitted a PR that resolves this issue. Please consider merging.

My PR has been merged, resolving this.

svnm commented

Thanks, merged in, should be in 2.0.5 👍