Skip to content

Commit

Permalink
only add/remove if applicable, support weird focus cases, #1147
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jan 27, 2021
1 parent ce1154b commit 40eca0b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/listeners/PressListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,9 @@ class PressListener {
'cannot focus node with zero or multiple accessible displays attached' );
//
this.display = accessibleDisplays[ 0 ];
this.display.focusHighlightsVisibleProperty.link( this.boundInvalidateOverListener );
if ( !this.display.focusHighlightsVisibleProperty.hasListener( this.boundInvalidateOverListener ) ) {
this.display.focusHighlightsVisibleProperty.link( this.boundInvalidateOverListener );
}

// On focus, button should look 'over'.
this.isFocusedProperty.value = true;
Expand All @@ -907,7 +909,9 @@ class PressListener {
*/
blur() {
if ( this.display ) {
this.display.focusHighlightsVisibleProperty.unlink( this.boundInvalidateOverListener );
if ( this.display.focusHighlightsVisibleProperty.hasListener( this.boundInvalidateOverListener ) ) {
this.display.focusHighlightsVisibleProperty.unlink( this.boundInvalidateOverListener );
}
this.display = null;
}

Expand Down

0 comments on commit 40eca0b

Please sign in to comment.