Skip to content

Commit a63dc26

Browse files
committed
Merge branch 'extraFocusFix'
2 parents 5de05c6 + a0de487 commit a63dc26

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Interactive extends React.Component {
3636
buttonDown: false,
3737
clickType: 'reset',
3838
focus: false,
39-
previousFocus: 'reset',
39+
previousFocus: false,
4040
focusTransition: 'reset',
4141
focusStateOnMouseDown: false,
4242
spaceKeyDown: false,
@@ -504,6 +504,7 @@ class Interactive extends React.Component {
504504
if (this.track.state.focus && !newState.focus) {
505505
setNON('blur');
506506
this.manageSetTimeout('elementBlur', () => {
507+
this.track.previousFocus = false;
507508
cancelNON('blur');
508509
}, queueTime);
509510
}
@@ -553,7 +554,7 @@ class Interactive extends React.Component {
553554
// window focus event
554555
case 'focus':
555556
// if the window focus event is not followed by an element focus event, then reset focus
556-
if (this.track.focus) {
557+
if (this.track.previousFocus !== false) {
557558
this.manageSetTimeout('windowFocus', () => {
558559
this.track.focus = false;
559560
}, queueTime);
@@ -566,8 +567,6 @@ class Interactive extends React.Component {
566567
this.cancelTimeout('elementBlur');
567568
// notifiy of the next window focus event (re-entering the app/window/tab)
568569
this.track.notifyOfNext.focus = notifyOfNext('focus', this.handleNotifyOfNext);
569-
// reinstate focus to it's previous value to preserve the focus state
570-
this.track.focus = this.track.previousFocus;
571570
break;
572571
default:
573572
}
@@ -1051,6 +1050,8 @@ class Interactive extends React.Component {
10511050
this.track.focus = 'mouse';
10521051
} else if (/touch/.test(focusTransition) || this.track.touchDown) {
10531052
this.track.focus = 'touch';
1053+
} else if (this.track.previousFocus) {
1054+
this.track.focus = this.track.previousFocus;
10541055
} else if (!/forceState/.test(focusTransition)) {
10551056
this.track.focus = 'tab';
10561057
}

0 commit comments

Comments
 (0)