Skip to content

Commit

Permalink
block input event after handling keydown for IE11 and Edge, see #413, p…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 28, 2018
1 parent 2535f6c commit 31b65dd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/accessibility/AccessibleSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,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 = {};

Expand Down Expand Up @@ -379,6 +384,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
Expand Down Expand Up @@ -509,7 +519,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;
Expand Down

0 comments on commit 31b65dd

Please sign in to comment.