Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Chávez <marco@expensify.com>
  • Loading branch information
mollfpr and marcochavezf authored Oct 31, 2022
1 parent c4aa933 commit 590dbac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/OptionsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ class OptionsList extends Component {

// We're setting `isScreenTouched` in this listener only for web platforms with touchscreen (mWeb) where
// we want to dismiss the keyboard only when the list is scrolled by the user and not when it's scrolled programmatically.
document.addEventListener('touchstart', this.userTouchStart);
document.addEventListener('touchend', this.userTouchEnd);
document.addEventListener('touchstart', this.touchStart);
document.addEventListener('touchend', this.touchEnd);
}

componentWillUnmount() {
if (!canUseTouchscreen()) {
return;
}

document.removeEventListener('touchstart', this.userTouchStart);
document.removeEventListener('touchend', this.userTouchEnd);
document.removeEventListener('touchstart', this.touchStart);
document.removeEventListener('touchend', this.touchEnd);
}

userTouchStart() {
this.isUserScreenTouched = true;
this.isScreenTouched = true;
}

userTouchEnd() {
this.isUserScreenTouched = false;
this.isScreenTouched = false;
}

render() {
Expand All @@ -50,7 +50,7 @@ class OptionsList extends Component {
ref={this.props.forwardedRef}
onScroll={() => {
// Only dismiss the keyboard whenever the user scrolls the screen
if (!this.isUserScreenTouched) {
if (!this.isScreenTouched) {
return;
}
Keyboard.dismiss();
Expand Down

0 comments on commit 590dbac

Please sign in to comment.