phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

AccessibleValueHandler shouldn't voice an empty Utterance #838

Closed jessegreenberg closed 1 year ago

jessegreenberg commented 1 year ago

Over in a usage in paper-land (https://github.com/phetsims/paper-land) we found that Utterances unrelated to an AccessibleValueHandler are never getting heard because an Utterance with an empty alert is getting voiced by the AccessibleValueHandler at the end of interaction.

As a workaround in paper-land, we added a high priority value to the Utterance we need to hear after moving a slider. But it would be best if AccessibleValueHandler didn't attempt to speak an Utterance with empty content.

jessegreenberg commented 1 year ago

I thought we decided to not voice empty strings, so I was curious why this empty Utterance is getting added to the UtteranceQueue. Indeed, I see this which is trying to prevent it.

https://github.com/phetsims/scenery/blob/9817f390330615133eb0e1d1404906b7dbce5edd/js/accessibility/voicing/Voicing.ts#L335-L339

Perhaps that check should use Utterance.alertableToText to check for emtpy content.

jessegreenberg commented 1 year ago

I reviewed with @zepumph who reminded me that Utterance.alertableToText may have side effects and cannot be used in common code like that. Instead, we are going to add the check right to AccessibleValueHandler. We did this in the above commit. I tested ratio-and-proportion after the change. Closing.