Skip to content

Commit

Permalink
replace event.target to event.currentTarget
Browse files Browse the repository at this point in the history
see more in DefinitelyTyped/DefinitelyTyped#11508 (comment)
or in react-dom.js flow types SyntheticEvent
  • Loading branch information
DragorWW committed Jan 24, 2019
1 parent bbb66fd commit 4eb3ee4
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Select.js
Expand Up @@ -886,13 +886,11 @@ export default class Select extends Component<Props, State> {
} 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();
}
};
Expand Down Expand Up @@ -1012,15 +1010,12 @@ export default class Select extends Component<Props, State> {
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();
}
Expand Down

0 comments on commit 4eb3ee4

Please sign in to comment.