phetsims / gas-properties

"Gas Properties" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 6 forks source link

Should I hear a sound when jumping to min/max? #281

Closed Nancy-Salpepi closed 4 days ago

Nancy-Salpepi commented 1 week ago

Test device MacBook Air M1 chip

Operating System 14.5

Browser Chrome

Problem description https://github.com/phetsims/qa/issues/1100, on all screens when I jump to the min/max of the number spinners there is no sound. There is a sound when I jump to the min/max of a slider. I know that these are UI sounds that were "turned on" for the sim, so if this is scope creep than feel free to ignore!

Steps to reproduce On any screen, tab to a number spinner and press the home and end keys.

pixelzoom commented 4 days ago

Reproduced in main, this affects all sims that have NumberSpinner and FineCoaseSpinner.

NumberSpinner and FineCoaseSpinner are common-code components that extends AccessibleNumberSpinner, which extends AccessibleValueHandler. @jessegreenberg was it an intentional part of the design not to have Home/End sounds for these UI components, or is this an oversight?

pixelzoom commented 4 days ago

@jessegreenberg is out this week, so this may be blocked until 7/8.

arouinfar commented 4 days ago

@pixelzoom I'm inclined to think this is an oversight. There's a possible paper trail in https://github.com/phetsims/fourier-making-waves/issues/192 and https://github.com/phetsims/sun/issues/697 that I'm still looking through.

pixelzoom commented 4 days ago

Summary from Slack#design-sims (see below) is that we should add sound for the Home/End buttons, and use the same sound as for the arrow buttons. I'll investigate how to do this.

Slack#design-sims @pixelzoom Alt input question for designers… In https://github.com/phetsims/gas-properties/issues/281, it was reported that (unlike sliders) spinners do not make a sound when using the Home/End keys to jump to max/min. Was this an intentional part of the design, or is this an implementation oversight (bug)? @arouinfar Does NumberSpinner use the slider sound API? @pixelzoom No. Slider extends AccessibleSlider. NumberSpinner extends AccessibleNumberSpinner. AccessibleSlider and AccessibleNumberSpinner both extend AccessibleValueHandler. @pixelzoom I don’t believe there’s any problem with the class hierarchy. But I believe that the Home/End key may not have been considered for AccessibleNumberSpinner. @pixelzoom Also note that (unlike sliders) spinners make the same sound for increment & decrement. And would presumable use the same sound for Home/End. The issue now is that there is no sound for Home/End. @arouinfar I found a similar [bug report in Fourier](https://github.com/phetsims/fourier-making-waves/issues/192), which is one of the first sims to have UI sound. I could not find any issues in sun or tambo about NumberSpinner sound. Since sims with UI sound only do not get tagged on the website, and I don’t have the ability to search all sim package.json, it’s difficult to find a paper trail for this sort of thing. @pixelzoom @jessegreenberg is out this week, so I can’t ask about the design and implementation. Also… I’d prefer not to get into redesigning sound for spinners. I’d just like to know if there should be sound for Home/End (I think yes) and if it’s OK to use the same sound as the increment/decrement arrows. (edited) @arouinfar agree, redesigning is out of scope, so reusing the increment/decrement sound for home/end seems reasonable.
pixelzoom commented 4 days ago

I've discovered that sound for NumberSpinner and FineCoarseSpinner is not handled by AccessibleNumberSpinner. Those classes actually press the buttons when arrow keys are pressed, which results in the buttons making sounds. For example in NumberSpinner:

    // pdom - NumberSpinner uses AccessibleValueHandler for accessibility, but it was decided that keyboardStep
    // and shiftKeyboardStep should have the same behavior as the NumberSpinner ArrowButtons AND the ArrowButtons
    // should look depressed when interacting with those keys. To accomplish this we actually press the ArrowButtons
    // in response to input with those keys. keyboardStep and shiftKeyboardStep are set to zero so the value isn't
    // modified again by AccessibleValueHandler. See https://github.com/phetsims/scenery/issues/1340.
    assert && assert( options.keyboardStep === undefined, 'NumberSpinner sets keyboardStep, it will be the same as deltaValue' );
    assert && assert( options.shiftKeyboardStep === undefined, 'NumberSpinner sets shiftKeyboardStep, it will be the same as deltaValue' );
    assert && assert( options.pageKeyboardStep === undefined, 'NumberSpinner sets pageKeyboardStep, it should not be used with NumberSpinner' );
    options.keyboardStep = 0;
    options.shiftKeyboardStep = 0;
    options.pageKeyboardStep = 0;
...
    // pdom - click arrow buttons on press of arrow keys so that the Property value changes by deltaValue
    // and the buttons look depressed
    const increasedListener = ( isDown: boolean ) => ( isDown && incrementButton.pdomClick() );
    const decreasedListener = ( isDown: boolean ) => ( isDown && decrementButton.pdomClick() );
    this.pdomIncrementDownEmitter.addListener( increasedListener );
    this.pdomDecrementDownEmitter.addListener( decreasedListener );
pixelzoom commented 4 days ago

Moving the general issue of adding Home/End sounds to https://github.com/phetsims/sun/issues/886. This issue is blocked until that is resolved.

pixelzoom commented 4 days ago

To unblock this issue, I created sim-specific subclasses of NumberSpinner and FineCoarseSpinner that add sound for the Home/End buttons, see https://github.com/phetsims/gas-properties/commit/280850da784b3695b43134c20f06716b3f4d1801. Those subclasses will need to be removed when this problem has been addressed generally in https://github.com/phetsims/sun/issues/886, as I've noted in that issue and a TODO code comment.

pixelzoom commented 4 days ago

@Nancy-Salpepi please review, close if OK. Home/End should make the same sound left/right/up/down keys.

Nancy-Salpepi commented 4 days ago

I now hear sounds when jumping to min/max.

One oddity I see is if I am already at the max value and press the up or right arrow I won't hear a sound, but if I press the End key I will still get a sound. The same things happens when at the min value.

pixelzoom commented 4 days ago

@Nancy-Salpepi said:

One oddity I see is if I am already at the max value and press the up or right arrow I won't hear a sound, but if I press the End key I will still get a sound. The same things happens when at the min value.

Discussed with @Nancy-Salpepi ... To clarify, we're hearing the Home/End sounds when we're already at max/min. That's undesirable, and not like (for example) Slider.

Unfortunately, I can’t check the value to see if we’re at max/min already, because NumberSpinner (AccessibleValueHandler probably) is setting the value to max/min before my workaround code is called. I don’t think that’s worth holding things up. So we will live with this workaround. I’ll make a note to handle it properly in https://github.com/phetsims/sun/issues/886. And I'll close this issue.