Merge pull request #3960 from OZhurbenko/dropdown-listeners-fix

HTML5 - dropdown click listeners' fix
This commit is contained in:
Anton Georgiev 2017-05-25 13:57:52 -04:00 committed by GitHub
commit 4a4cb684ac

View File

@ -82,11 +82,17 @@ class Dropdown extends Component {
}
handleShow() {
const { addEventListener } = window;
addEventListener('click', this.handleWindowClick, false);
this.setState({ isOpen: true }, this.handleStateCallback);
}
handleHide() {
const { removeEventListener } = window;
removeEventListener('click', this.handleWindowClick, false);
const { autoFocus } = this.props;
this.setState({ isOpen: false }, this.handleStateCallback);
@ -97,16 +103,6 @@ class Dropdown extends Component {
}
}
componentDidMount () {
const { addEventListener } = window;
addEventListener('click', this.handleWindowClick, false);
}
componentWillUnmount () {
const { removeEventListener } = window;
removeEventListener('click', this.handleWindowClick, false);
}
handleWindowClick(event) {
const dropdownElement = findDOMNode(this);
const shouldUpdateState = event.target !== dropdownElement &&