Skip to content

Commit

Permalink
address TODO by fixing reference to listener for disposal, see #314
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Jan 16, 2019
1 parent 87fe8f4 commit d130055
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ define( require => {
// tracks which item node has focus to make it easy to focus next/previous item after keydown
this.focusedItem = null;

// TODO: sun#314 is this how you have a reference to a listener to remove?
// keep track of the input listener for removal
const handleKeyDown = this.listNode.addInputListener( {
const keyDownListener = {
keydown: event => {
var domEvent = event.domEvent;
if ( domEvent.keyCode === KeyboardUtil.KEY_ESCAPE ) {
Expand Down Expand Up @@ -256,7 +255,8 @@ define( require => {
this.hideList();
}
}
} );
};
this.listNode.addInputListener( keyDownListener );

// @private button that shows the current selection
this.button = new ComboBoxButton( property, items, {
Expand Down Expand Up @@ -341,7 +341,7 @@ define( require => {
}

// remove a11y listeners
this.listNode.removeInputListener( handleKeyDown );
this.listNode.removeInputListener( keyDownListener );

this.button.dispose();
};
Expand Down

0 comments on commit d130055

Please sign in to comment.