Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	js/accessibility/AccessibleValueHandler.js
  • Loading branch information
twant committed Oct 1, 2019
2 parents f036536 + 8aba374 commit 90fb4c4
Showing 1 changed file with 2 additions and 43 deletions.
45 changes: 2 additions & 43 deletions js/accessibility/AccessibleValueHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ define( require => {
const StringUtils = require( 'PHETCOMMON/util/StringUtils' );
const sun = require( 'SUN/sun' );
const SunConstants = require( 'SUN/SunConstants' );
const timer = require( 'AXON/timer' );
const Util = require( 'DOT/Util' );
const Utterance = require( 'SCENERY_PHET/accessibility/Utterance' );
const utteranceQueue = require( 'SCENERY_PHET/accessibility/utteranceQueue' );
Expand Down Expand Up @@ -156,23 +155,7 @@ define( require => {
* should list any Properties who's change should trigger description update for this Node.
* @type {Property[]}
*/
a11yDependencies: [],

/**
* By default there will be nothing special provided on focus, just the previous value set on Property change.
* If a specific aria-valuetext is desired when the interactive DOM element is focused, then use this option
* to provide the proper "on focus" text. If provided, this will be called independently of the "on change"
* valuetext updates. As a result, you can use either a11yCreateAriaValueText or a11yValuePattern
* with this.
*
* The string that this function returns is set as aria-valuetext when the component is focused.
*
* @type {null|Function}
* @param {number} formattedValue - mapped value fixed to the provided decimal places
* @param {number} value - the current value of the Property, unformatted
* @returns {string} - aria-valuetext to be set to the primarySibling
*/
a11yCreateOnFocusAriaValueText: null
a11yDependencies: []
};

options = _.extend( {}, defaults, options );
Expand Down Expand Up @@ -284,9 +267,6 @@ define( require => {
// @private {Multilink}
this._dependenciesMultilink = null;

// @private - {null|function} see options for doc
this.a11yCreateOnFocusAriaValueText = options.a11yCreateOnFocusAriaValueText;

// @private {boolean} see options for doc
this._a11yRepeatEqualValueText = options.a11yRepeatEqualValueText;

Expand Down Expand Up @@ -322,19 +302,9 @@ define( require => {
};
this._valueProperty.link( valuePropertyListener );

const valueHandlerListener = {

// When not providing a timeout, we would often get this change for the previously focused element even
// though it wasn't the active element of the screen. Perhaps this is just a bug/problem with how AT monitor
// for aria-valuetext updating.
focus: () => { timer.setTimeout( () => this.updateOnFocusAriaValueText(), 0 );}
};
this.addInputListener( valueHandlerListener );

// @private - called by disposeAccessibleValueHandler to prevent memory leaks
this._disposeAccessibleValueHandler = () => {
this._rangeProperty.unlink( enabledRangeObserver );
this.removeInputListener( valueHandlerListener );
this._valueProperty.unlink( valuePropertyListener );
this._dependenciesMultilink && this._dependenciesMultilink.dispose();
};
Expand Down Expand Up @@ -410,8 +380,7 @@ define( require => {

// 700 and 2000 ms are arbitrary values but sound good with limited testing. We want to give enough time
// for VO to read aria-valuetext but don't want to have too much silence before the alert is spoken.
const delayTime = Math.min( this.timesChangedBeforeAlerting * 700, 2000 );
this.utterance.alertStableDelay = delayTime;
this.utterance.alertStableDelay = Math.min( this.timesChangedBeforeAlerting * 700, 2000 );

utteranceQueue.addToBack( this.utterance );
}
Expand All @@ -430,16 +399,6 @@ define( require => {
this.updateAriaValueText( null );
},

/**
* @public
* Update the aria-valuetext for the next time that this element is focused.
*/
updateOnFocusAriaValueText() {
if ( this.a11yCreateOnFocusAriaValueText ) {
this.ariaValueText = this.a11yCreateOnFocusAriaValueText( this.getA11yFormattedValue(), this._valueProperty.value );
}
},

/**
* @private
* get the formatted value based on the current value of the Property.
Expand Down

0 comments on commit 90fb4c4

Please sign in to comment.