Closed KatieWoe closed 8 months ago
This was noted in https://github.com/phetsims/fourier-making-waves/issues/243#issuecomment-1877712735, and may be related to that issue. But I'll leave this open as a separate issue.
In the Discrete screen, the value of the "Function of" (domain) combo box determines which items are visible in the "Equation" combo box:
The problem here occurs with multitouch. It's possible for the selected item to become invisible before its sound plays. That results in an assertion failure in ComboBoxListBox. Here's the assertion, which @jbphet and I added recently in https://github.com/phetsims/sun/commit/9dffc8949c85727c9e2328a00ef18cfaa8967d7a for https://github.com/phetsims/sun/issues/862:
// The selected item didn't provide a sound player, so use a default based on its position within the list
// of visible selections.
const selectionIndex = this.getVisibleListItemNodes().indexOf( this.selectionOnFireAction );
assert && assert( selectionIndex !== -1, 'sound generation does not support adding new items' );
defaultItemSelectedSoundPlayers[ selectionIndex ].play();
My inclination is to change this to something like the following. But I'll discuss with @jbphet first.
// The selected item didn't provide a sound player, so use a default based on its position within the list
// of visible selections. With multitouch, it's possible that the selected item may become invisible before
// we attempt to play its sound, so play only if it's still visible.
// See https://github.com/phetsims/fourier-making-waves/issues/244
const selectionIndex = this.getVisibleListItemNodes().indexOf( this.selectionOnFireAction );
if ( selectionIndex !== -1 ) {
defaultItemSelectedSoundPlayers[ selectionIndex ].play();
}
I discussed with @jbphet, and he supported the change in https://github.com/phetsims/sun/commit/ab87ee8579ce5abe183e2002d186eadbcf37ce72.
Since the failing assertion no longer exists, I feel comfortable closing this without waiting a few CT cycles.