Skip to content

Commit

Permalink
Fix edge case where notifyOfNext focus could be set more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
rafgraph committed May 3, 2017
1 parent 9452d14 commit 3c64f8b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,9 @@ class Interactive extends React.Component {
// clear the timer set in manageNotifyOfNext that was set to cancel this notification
this.cancelTimeout('elementBlur');
// notifiy of the next window focus event (re-entering the app/window/tab)
this.track.notifyOfNext.focus = notifyOfNext('focus', this.handleNotifyOfNext);
if (!this.track.notifyOfNext.focus) {
this.track.notifyOfNext.focus = notifyOfNext('focus', this.handleNotifyOfNext);
}
break;
default:
}
Expand Down Expand Up @@ -1034,7 +1036,8 @@ class Interactive extends React.Component {
// This is only a problem on Android Chrome because despite not calling focus on link tap,
// upon returning to the window, focus is called on the element putting it
// into the focusFromTab state, when it should be in the focusFromTouch state.
if (this.p.props.target === '_blank' && this.track.clickType === 'tapClick') {
if (this.p.props.target === '_blank' && this.track.clickType === 'tapClick' &&
!this.track.notifyOfNext.focus) {
this.track.previousFocus = 'touch';
this.track.notifyOfNext.focus = notifyOfNext('focus', this.handleNotifyOfNext);
}
Expand Down

0 comments on commit 3c64f8b

Please sign in to comment.