Skip to content

Commit

Permalink
separate model from view: focus method, #814
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 4, 2018
1 parent f65fe9c commit df8d387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/accessibility/Accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ define( function( require ) {
assert && assert( this._accessibleVisible, 'trying to set focus on a node with invisible accessible content' );
assert && assert( this._accessibleInstances.length === 1, 'focus() unsupported for Nodes using DAG, accessible content is not unique' );

this._accessibleInstances[ 0 ].peer.primarySibling.focus();
var peer = this._accessibleInstances[ 0 ].peer;
assert && assert( peer, 'must have a peer to focus' );
peer.focus();
}
},

Expand Down
8 changes: 8 additions & 0 deletions js/accessibility/AccessiblePeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ define( function( require ) {
return document.activeElement === this.primarySibling;
},

/**
* Focus the primary sibling of the peer.
*/
focus: function() {
assert && assert( this.primarySibling, 'must have a primary sibling to focus' );
this.primarySibling.focus();
},


/**
* Removes external references from this peer, and places it in the pool.
Expand Down

0 comments on commit df8d387

Please sign in to comment.