Skip to content

Commit

Permalink
voicing and pdom visibility for modal dialogs should be handled in th…
Browse files Browse the repository at this point in the history
…e same place in Sim, phetsims/ratio-and-proportion#509 #293
  • Loading branch information
zepumph committed Oct 7, 2022
1 parent 6487f35 commit 7f6ba85
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions js/Sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,12 @@ export default class Sim extends PhetioObject {
if ( isModal ) {
this.rootNode.interruptSubtreeInput();
this.modalNodeStack.push( popup );

// pdom - modal dialogs should be the only readable content in the sim
this.setPDOMViewsVisible( false );

// voicing - responses from Nodes hidden by the modal dialog should not voice.
this.setNonModalVoicingVisible( false );
}
if ( popup.layout ) {
popup.layout( this.screenBoundsProperty.value! );
Expand All @@ -837,6 +843,12 @@ export default class Sim extends PhetioObject {
assert && assert( this.topLayer.hasChild( popup ), 'popup was not shown' );
if ( isModal ) {
this.modalNodeStack.remove( popup );
if ( this.modalNodeStack.length === 0 ) {
this.setNonModalVoicingVisible( true );

// pdom - when the dialog is hidden, make all ScreenView content visible to assistive technology
this.setPDOMViewsVisible( true );
}
}
this.topLayer.removeChild( popup );
}
Expand Down Expand Up @@ -1024,7 +1036,7 @@ export default class Sim extends PhetioObject {
* remain visible, but not be tab navigable or readable with a screen reader. This is generally useful when
* displaying a pop up or modal dialog.
*/
public setAccessibleViewsVisible( visible: boolean ): void {
public setPDOMViewsVisible( visible: boolean ): void {
for ( let i = 0; i < this.screens.length; i++ ) {
this.screens[ i ].view.pdomVisible = visible;
}
Expand All @@ -1041,13 +1053,21 @@ export default class Sim extends PhetioObject {
* only Toolbar content is announced.
*/
public setSimVoicingVisible( visible: boolean ): void {
this.setNonModalVoicingVisible( visible );
this.topLayer && this.topLayer.setVoicingVisible( visible );
}

/**
* Sets voicingVisible on all elements "behind" the modal node stack. In this case, voicing should not work for those
* components when set to false.
* @param visible
*/
public setNonModalVoicingVisible( visible: boolean ): void {
for ( let i = 0; i < this.screens.length; i++ ) {
this.screens[ i ].view.voicingVisible = visible;
this.screens[ i ].view.voicingVisible = visible; // home screen is the first item, if created
}

this.navigationBar.voicingVisible = visible;
this.topLayer && this.topLayer.setVoicingVisible( visible );
this.homeScreen && this.homeScreen.view.setVoicingVisible( visible );
}
}

Expand Down

0 comments on commit 7f6ba85

Please sign in to comment.