Closed zepumph closed 1 year ago
@jessegreenberg and I spoke about this last Friday. It isn't totally obvious what the best solution is, but we decided that it was worth trying to add in Voicing to AccessibleValueHandler, and to try create public methods that act as the rule-based "events" that sliders have for mouse/touch/keyboard interactions. We can call them privately to handle keyboard, and expect that for mouse input, the voicing design pattern is to use the AccessibleValueHandler functions instead of calling upon the Voicing mixin directly.
From our meeting, it wasn't totally clear if the complexity of adding voicing directly to AccessibleValueHandler was worth the benefit. Right now, the "benefit" is another way of doing the same thing for voicing. I still think it is worth a try though, so I will work on this as part of https://github.com/phetsims/ratio-and-proportion/issues/413
The first step here was to preemptively handle the issue I ran into over in https://github.com/phetsims/scenery/issues/1283#issuecomment-992800551, where many times we were mutating voicing options before initializing voicing. If we mix Voicing into AccessibleValueHandler as part of that work, we will want to make sure we don't hit that, so I refactored mutate
calls above.
This is failing several sims on CT, increasing priority.
The failure is
Node.ts:5896 Uncaught TypeError: this._enabledProperty.initializePhetio is not a function
at BLLFaucetNode.initializePhetioObject (Node.ts:5896)
at BLLFaucetNode.mutate (Node.ts:5856)
at new FaucetNode (FaucetNode.js? [sm]:286)
at new BLLFaucetNode (BLLFaucetNode.js? [sm]:43)
at new ConcentrationScreenView (ConcentrationScreenView.js? [sm]:83)
at ConcentrationScreen.createView (ConcentrationScreen.js? [sm]:40)
at ConcentrationScreen.initializeView (Screen.js? [sm]:254)
at Array.<anonymous> (Sim.js? [sm]:773)
at Sim.js? [sm]:781
Reverting https://github.com/phetsims/scenery-phet/commit/486cf2be4a28a6187888c7e140b0aaf66cb9b6e8 prevents the problem.
Another CT error that appeared at the same time is:
graphing-quadratics : phet-io-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1639496160983/graphing-quadratics/graphing-quadratics_en.html?continuousTest=%7B%22test%22%3A%5B%22graphing-quadratics%22%2C%22phet-io-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1639496160983%22%2C%22timestamp%22%3A1639499574034%7D&ea&brand=phet-io&phetioStandalone&fuzz&memoryLimit=1000
Query: ea&brand=phet-io&phetioStandalone&fuzz&memoryLimit=1000
Uncaught Error: Assertion failed: this means addLinkedElement was called before instrumentation of this PhetioObject
Error: Assertion failed: this means addLinkedElement was called before instrumentation of this PhetioObject
at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1639496160983/assert/js/assert.js:25:13)
at NumberPicker.initializePhetioObject (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1639496160983/chipper/dist/js/tandem/js/PhetioObject.js:173:15)
...
Which seems like it may relate to the order of Node instrumentation (in the mutate call), so should be investigated as part of this issue as well.
Two fixes here. The enabledProperty one was sneaky, we have been overwriting Node's enabledProperty in AccessibleValueProperty for god know's how long, but since we instrumented it first (mutate before initializeAccessibleSlider), it didn't cause problems. I sorted it out with a rename.
Still working here:
I sorta gave up on creating an ideal, general API, in part because the design for sliders may change on a case by case basis, and complexity may need to be added. In the mean time, I worked on https://github.com/phetsims/ratio-and-proportion/issues/413 and put the code needed into AccessibleValueHandler. Above is the addition of Voicing into AccessibleValueHandler, along with new functions that signify events (end/change) to help generalize the life cycle of voicing a slider. I think these will be able to be reused in other sims, but perhaps with some tweaks. It isn't perfect, but in general these methods are called in the keyboard listeners internally, and publicly by the mouse dragListener. I'll discuss with designer more on the sim-specific design, and then come back here.
I had to make sure to remove other usages of initializeVoicing where we are also extending AccessibleValueHandler. @jessegreenberg, is it alright to mutate the options in AppendageNode at the end of the constructor?
This is looking really nice! I moved the mutate
to the end in AppendageNode and removed the extra initializeVoicing
in both john-travoltage and inverse-square-law-common and gravity-force-lab-basics and tested, it is working well.
in general these methods are called in the keyboard listeners internally, and publicly by the mouse dragListener.
It looks like so far voicingOnEndResponse
is the only one called internally, is that right?
Yes that's right, because focus occurs by default on focus.
I cleaned up the rest of the usages of Voicing in those three files. Sound alright?
https://github.com/phetsims/ratio-and-proportion/issues/413 has been signed off on, so we need to clean up this implementation in common code. We went with an approach that had custom implementations for Mouse/Touch that didn't use AccessibleValueHandler.
Cleanup done above. I removed the "opt in" approach, but this didn't seem to effect the voicing I was hearing in GFLB or JT, so I committed.
@zepumph can this be closed now? Slider + Voicing work also happened in https://github.com/phetsims/joist/issues/854.
We need to support voicing in cases where we are using AccessibleValueHandler (often via AccessibleSlider). I tried to name this issue such that it didn't automatically sound like we were going to implement Voicing directly into AccessibleValueHandler. I don't know if that is the best approach. In general, sliders need a smooth API for adding voicing to them, and it will largely overlap with AccessibleValueHandler because voicing utilized alternative input (supported via AccessibleValueHandler). One context here is that in RAP, I am adding voicing to the hand sliders (https://github.com/phetsims/ratio-and-proportion/issues/413). These Nodes mix AccessibleSlider, but currently have a custom implementation to support voicing. Is there a way that we can align these APIs via common code design?
It is also important to note that voiced sliders will always support mouse/touch in addition to alt input, so we need to think more broadly than AccessibleValueHandler, even if we utilize it to achieve some of the voicing api for sliders.
I think the best place to start is with a conversation with @jessegreenberg, marking for meeting.