From 9ee727594b3e000cd6604a4a465d2ceec95fbaf5 Mon Sep 17 00:00:00 2001 From: Jesse Date: Wed, 28 Nov 2018 17:22:53 -0500 Subject: [PATCH] block input event after handling keydown for IE11 and Edge, see #413, phetsims/coulombs-law#92, and phetsims/coulombs-law#86 --- js/accessibility/AccessibleSlider.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/accessibility/AccessibleSlider.js b/js/accessibility/AccessibleSlider.js index 5c4a5393..a731b9af 100644 --- a/js/accessibility/AccessibleSlider.js +++ b/js/accessibility/AccessibleSlider.js @@ -183,6 +183,11 @@ define( function( require ) { // input event in case a device sends both events to the browser. this.a11yInputHandled = false; + // @private (a11y) - some browsers will receive `input` events when the user tabs away from the slider or + // on some key presses - if we receive a keydown event, we do not want the value to change twice, so we + // block input event after handling the keydown event + this.blockInput = false; + // @private - entries like { {number}: {boolean} }, key is range key code, value is whether it is down this.rangeKeysDown = {}; @@ -367,6 +372,11 @@ define( function( require ) { handleKeyDown: function( event ) { var code = event.keyCode; this._shiftKey = event.shiftKey; + + // if we receive a keydown event, we shouldn't handle any input events (which should only be provided + // directly by an assistive device) + this.blockInput = true; + if ( this._enabledProperty.get() ) { // Prevent default so browser doesn't change input value automatically @@ -497,7 +507,7 @@ define( function( require ) { * @param {DOMEvent} event */ handleInput: function( event ) { - if ( this._enabledProperty.get() ) { + if ( this._enabledProperty.get() && !this.blockInput ) { // don't handle again on "change" event this.a11yInputHandled = true;