From d1300551136c59a312af8b4b3f5a08402f88b516 Mon Sep 17 00:00:00 2001 From: Jesse Date: Wed, 16 Jan 2019 18:22:07 -0500 Subject: [PATCH] address TODO by fixing reference to listener for disposal, see #314 --- js/ComboBox.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/ComboBox.js b/js/ComboBox.js index 8a025352..2e3d69f5 100644 --- a/js/ComboBox.js +++ b/js/ComboBox.js @@ -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 ) { @@ -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, { @@ -341,7 +341,7 @@ define( require => { } // remove a11y listeners - this.listNode.removeInputListener( handleKeyDown ); + this.listNode.removeInputListener( keyDownListener ); this.button.dispose(); };