Skip to content

Commit

Permalink
remove the default TinyProperty in canAnnounceProperties, see #79
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Apr 16, 2022
1 parent 76a9517 commit c2b6ad4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/Utterance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Utterance {
const options = optionize<UtteranceOptions>( {
alert: null,
predicate: function() { return true; },
canAnnounceProperties: [ new TinyProperty<boolean>( true ) ],
canAnnounceProperties: [],
alertStableDelay: 200,
alertMaximumDelay: Number.MAX_VALUE,
announcerOptions: {},
Expand Down Expand Up @@ -232,13 +232,14 @@ class Utterance {
* this.canAnnounceProperty.
*/
public setCanAnnounceProperties( canAnnounceProperties: IProperty<boolean>[] ): void {
assert && assert( canAnnounceProperties.length > 0, 'There must be at least once dependency canAnnounceProperty' );

if ( this.canAnnounceImplementationProperty.value ) {
this.canAnnounceImplementationProperty.value.dispose();
}

const canSpeakProperty = DerivedProperty.and( canAnnounceProperties );
// If no canAnnounceProperties provided, use a dummy Property that will always allow this Utterance to announce.
const dependencyProperties = canAnnounceProperties.length === 0 ? [ new TinyProperty( true ) ] : canAnnounceProperties;

const canSpeakProperty = DerivedProperty.and( dependencyProperties );
this.canAnnounceImplementationProperty.value = canSpeakProperty;

this._canAnnounceProperties = canAnnounceProperties;
Expand Down

0 comments on commit c2b6ad4

Please sign in to comment.