From 958925131d8bb73d3de6942609ac51e3e8649ba1 Mon Sep 17 00:00:00 2001 From: Andreev Sergey Date: Fri, 25 Jan 2019 00:21:21 +0700 Subject: [PATCH] replace event.target to event.currentTarget see more in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682 or in react-dom.js flow types SyntheticEvent https://flow.org/en/docs/react/events/ --- src/Select.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Select.js b/src/Select.js index 534a041ef6..4981c2d508 100644 --- a/src/Select.js +++ b/src/Select.js @@ -886,13 +886,11 @@ export default class Select extends Component { } else if (!this.props.menuIsOpen) { this.openMenu('first'); } else { - // $FlowFixMe HTMLElement type does not have tagName property - if (event.target.tagName !== 'INPUT') { + if (event.currentTarget.tagName !== 'INPUT') { this.onMenuClose(); } } - // $FlowFixMe HTMLElement type does not have tagName property - if (event.target.tagName !== 'INPUT') { + if (event.currentTarget.tagName !== 'INPUT') { event.preventDefault(); } }; @@ -1012,15 +1010,12 @@ export default class Select extends Component { onTouchEnd = (event: TouchEvent) => { if (this.userIsDragging) return; - // type cast the EventTarget - const target = ((event.target: any): HTMLElement); - // close the menu if the user taps outside if ( this.controlRef && - !this.controlRef.contains(target) && + !this.controlRef.contains(event.currentTarget) && this.menuListRef && - !this.menuListRef.contains(target) + !this.menuListRef.contains(event.currentTarget) ) { this.blurInput(); }