Skip to content

Commit

Permalink
prevent bug where focus can get lost if full screen initiated from if…
Browse files Browse the repository at this point in the history
…rame, see #883
  • Loading branch information
jessegreenberg committed Oct 29, 2018
1 parent f61fc22 commit 8985085
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions js/accessibility/AccessibleInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define( function( require ) {
var AccessiblePeer = require( 'SCENERY/accessibility/AccessiblePeer' );
var cleanArray = require( 'PHET_CORE/cleanArray' );
var Events = require( 'AXON/Events' );
var FullScreen = require( 'SCENERY/util/FullScreen' );
var inherit = require( 'PHET_CORE/inherit' );
var KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' );
var platform = require( 'PHET_CORE/platform' );
Expand Down Expand Up @@ -131,6 +132,18 @@ define( function( require ) {

scenery.Display.userGestureEmitter.emit();

// If navigating in full screen mode, prevent a bug where focus gets lost if fullscreen mode was initiated
// from an iframe by keeping focus in the display. getNext/getPreviousFocusable will return active element
// if there are no more elements in that direction. See https://github.com/phetsims/scenery/issues/883
if ( FullScreen.isFullScreen() && event.keyCode === KeyboardUtil.KEY_TAB ) {
var rootElement = self.display.accessibleDOMElement;
var nextElement = event.shiftKey ? AccessibilityUtil.getPreviousFocusable( rootElement ) :
AccessibilityUtil.getNextFocusable( rootElement );
if ( nextElement === event.target ) {
event.preventDefault();
}
}

// if an accessible node was being interacted with a mouse, or had focus when sim is made inactive, this node
// should receive focus upon resuming keyboard navigation
if ( self.display.pointerFocus || self.display.activeNode ) {
Expand Down

0 comments on commit 8985085

Please sign in to comment.