Closed zepumph closed 2 years ago
This went smoothly for RectangularRadioButton. I committed the simple line change above. @jessegreenberg it would be good to take a look at that to confirm.
It was much weirder for AquaRadioButton. I made a patch below to note my progress. It is not a ButtonNode, so I tried to compose Voicing into AquaRadioButton.
The issue was that upon selecting new items with arrow keys, the next AquaRadioButtons gets focused. I traced it back to this line in Input.js. I'm unsure why there is this discrepancy between radio button implementations.
Steps to reproduce:
The issue here is that we can't hard code this in common code if it happens on selection too, because selection often removes the object response because it is part of the context response. @jessegreenberg please advise. Note that this isn't blocking Ratio and proportion, but means that the radio buttons in common code have an inconsistent state and API between each other.
Actually, @jessegreenberg and I just paired and this does in fact block Ratio and Proportion. I found that RectangularRadioButton was also getting these focus callbacks, but the Property lazyLink voicing utterance was overwriting it immediately.
@jessegreenberg and I discussed, and feel like it makes sense that the object response for the buttons would always be on focus, even on activation. After the above bug fix, we are able to use cancelOther: false
to allow both the object response from the focus listener and the context response from the Property listener.
This is a bit inflexible, but I would like to see how far we can get with it.
I will commit the addition to AquaRadioButtonGroup as well.
ARG!! @jessegreenberg I just realized this approach won't work for mouse/interactive highlights to give the object response. I'll keep thinking about it. I can't think of a way to have focus take the object response until it "can't." And then to have the Property handle it instead.
I guess in this case we need the object response on both focus and down. This wouldn't work after what was proposed in https://github.com/phetsims/scenery/issues/1217, but would it work if you removed the check for event.type === 'focus'
in https://github.com/phetsims/sun/commit/861e30d87b75b71e7e0608f30176759249977f6a?
You would get the object response on press and on focus. Then the context response that follows from the Property listener with cancelOther: false
on the Utterance.
@jessegreenberg, have we solved this issue by creating the "Name Response"? On click or upon focus, the user will always get the Name Response, and then also get the Context Response if that checkbox is checked?
Yes @terracoda, I believe so. I renamed the issue to be align with the newer voicing api. @jessegreenberg, I hit this working on RaP, so I'll go ahead and take the lead on seeing what I can bring over from the preferences branch.
Right now I'm blocked on https://github.com/phetsims/scenery/issues/1349 for this.
This is all I found from the branch:
Index: js/buttons/RectangularRadioButton.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/buttons/RectangularRadioButton.js b/js/buttons/RectangularRadioButton.js
--- a/js/buttons/RectangularRadioButton.js (revision f1ee5bc82974cf0265aeef998ad88ab8fbb88783)
+++ b/js/buttons/RectangularRadioButton.js (date 1645636413893)
@@ -129,6 +129,9 @@
buttonModel.downProperty.link( down => {
if ( !down && ( buttonModel.overProperty.get() || buttonModel.focusedProperty.get() ) && !buttonModel.interrupted ) {
this.fire();
+
+ // voicing
+ this.voicingSpeakFullResponse();
}
} );
This was pretty straight forward. While I was in here, I also added support for context responses to be passed in the "Item" metadata. @jessegreenberg can you please review. Any more thoughts here?
Voicing change looks good to me! Passing through "item" is the API I would expect. Thanks!
Is there a need for hint responses for these buttons? Seems unlikely because you would have to select the button to hear it at which point it would be too late to be helpful. If no, feel free to close.
There was no hint response for the radio buttons in RAP. Perhaps we will want that support at somepoint, but it would be so easy to add that I feel like we shouldn't prematurely open up that API.
For clarity, note how the radio button rules recommend no hint response across the board.
Many radiobutton groups, do indeed have help text, but RaP's does not.
I think, help text will only be available for keyboard users for radio button groups. There seems like no need for help text for mouse and touch users.
I can plug in a way to have the group take the hint response, and then pass it to every radio button as it goes, then it will automatically show up on focus, but won't bleed in anywhere else.
Yep, would just want a hint on focus, if hints are checked.
Added above. This works as easily as with this patch:
Index: js/common/view/TickMarkViewRadioButtonGroup.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/view/TickMarkViewRadioButtonGroup.ts b/js/common/view/TickMarkViewRadioButtonGroup.ts
--- a/js/common/view/TickMarkViewRadioButtonGroup.ts (revision d2d7c89ee21d9b24bea875e4a3110c304b9ea18b)
+++ b/js/common/view/TickMarkViewRadioButtonGroup.ts (date 1645727075661)
@@ -37,7 +37,9 @@
// pdom
labelContent: ratioAndProportionStrings.a11y.tickMark.heading,
- helpTextBehavior: ParallelDOM.HELP_TEXT_BEFORE_CONTENT
+ helpTextBehavior: ParallelDOM.HELP_TEXT_BEFORE_CONTENT,
+
+ voicingHintResponse: 'oh what a hint it is'
}, options );
const radioButtonItemData = [ {
Thanks for chiming in @terracoda, I should have asked you about it instead of assuming.
Does this only announce the hint (if checked in preferences) on the initial focus - when focus enters the group and focus on the initially selected radio button? We do not want a hint upon a new selection when using the arrow keys.
Yes, only when hints are enabled with the checkbox.
And only on initial focus?
Ahhh! You got me! I had to omit the hint from the selection response. I made you a dev version, and put in a temporary hint for the tick mark radio buttons. Will you please review and see if it sounds correct for these cases? (It should be right now)
This is perfect @zepumph for when there is a hint for the radio group. Thanks for verifying with a test. You can close this issue now. We have a radio group/radio button pattern that should work well.
Excellent. I reverted the temp hint. Closing
From https://github.com/phetsims/ratio-and-proportion/issues/384, it seems that we can get an on-focus object response put into common code for all radio buttons. For selection, we usually defer to the usage to implement (for interactive description and voicing), but it should be easy enough to use labelContent to supply the voicing object response.
I'll do this for aqua and rectangular radio buttons.