Skip to content

Commit

Permalink
descriptionContent -> screenButtonsHelpText, see #989
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Nov 5, 2024
1 parent bb5b426 commit e3366b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions js/HomeScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class HomeScreenView extends ScreenView {
showUnselectedHomeScreenIconFrame: screen.showUnselectedHomeScreenIconFrame,

// pdom
descriptionContent: screen.descriptionContent,
descriptionContent: screen.screenButtonsHelpText,

// voicing
voicingHintResponse: screen.descriptionContent,
voicingHintResponse: screen.screenButtonsHelpText,

// phet-io
tandem: screen.tandem.supplied ? buttonGroupTandem.createTandem( `${screen.tandem.name}Button` ) : Tandem.REQUIRED
Expand Down Expand Up @@ -208,7 +208,7 @@ class HomeScreenView extends ScreenView {
}
details += StringUtils.fillIn( JoistStrings.a11y.homeScreenButtonDetailsPatternStringProperty, {
name: screenButton.screen.pdomDisplayNameProperty.value,
screenHint: screenButton.screen.descriptionContent
screenHint: screenButton.screen.screenButtonsHelpText
} );
} );
return details;
Expand Down
4 changes: 2 additions & 2 deletions js/NavigationBarScreenButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class NavigationBarScreenButton extends Voicing( Node ) {
// pdom
tagName: 'button',
containerTagName: 'li',
descriptionContent: screen.descriptionContent,
descriptionContent: screen.screenButtonsHelpText,
appendDescription: true,

// voicing
voicingHintResponse: screen.descriptionContent
voicingHintResponse: screen.screenButtonsHelpText
}, providedOptions );

assert && assert( !options.innerContent, 'NavigationBarScreenButton sets its own innerContent' );
Expand Down
27 changes: 14 additions & 13 deletions js/Screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ type SelfOptions = {
// dt cap in seconds, see https://github.com/phetsims/joist/issues/130
maxDT?: number;
createKeyboardHelpNode?: null | ( ( tandem: Tandem ) => Node );
descriptionContent?: PDOMValueType | null;

// Help text that will be added to the Home screen button and navigation bar button for this screen.
// This is often a full but short sentence with a period at the end of it. This is also used as the
// hint response for these buttons with the Voicing feature.
screenButtonsHelpText?: PDOMValueType | null;
};
export type ScreenOptions = SelfOptions &
StrictOmit<PhetioObjectOptions, 'tandemNameSuffix'> & // Tandem.RootTandem.createTandem requires that the suffix is Tandem.SCREEN_TANDEM_NAME_SUFFIX.
Expand All @@ -87,7 +91,7 @@ class Screen<M extends TModel, V extends ScreenView> extends PhetioObject {
// dt cap in seconds, see https://github.com/phetsims/joist/issues/130
public readonly maxDT: number;
public readonly activeProperty: BooleanProperty;
public readonly descriptionContent: PDOMValueType;
public readonly screenButtonsHelpText: PDOMValueType;
public readonly nameProperty: TReadOnlyProperty<string>;

public readonly showScreenIconFrameForNavigationBarFill: string | null;
Expand Down Expand Up @@ -144,10 +148,7 @@ class Screen<M extends TModel, V extends ScreenView> extends PhetioObject {
// screen is selected
createKeyboardHelpNode: null,

// pdom/voicing - The description that is used when interacting with screen icons/buttons in joist (and home screen).
// This is often a full but short sentence with a period at the end of it. This is also used for voicing this screen
// in the home screen.
descriptionContent: null,
screenButtonsHelpText: null,

// phet-io
// @ts-expect-error include a default for un-instrumented, JavaScript sims
Expand Down Expand Up @@ -236,19 +237,19 @@ class Screen<M extends TModel, V extends ScreenView> extends PhetioObject {
'simulations, there is only one screen and it is always active.'
} );

// Used to set the ScreenView's descriptionContent. This is a bit of a misnomer because Screen is not a Node
// subtype, so this is a value property rather than a setter.
this.descriptionContent = '';
if ( options.descriptionContent ) {
this.descriptionContent = options.descriptionContent;
this.screenButtonsHelpText = '';
if ( options.screenButtonsHelpText ) {
this.screenButtonsHelpText = options.screenButtonsHelpText;
}
else if ( this.nameProperty.value ) {
this.descriptionContent = new PatternStringProperty( screenNamePatternStringProperty, {

// Fall back to "{{Screen Name}} Screen" as a default.
this.screenButtonsHelpText = new PatternStringProperty( screenNamePatternStringProperty, {
name: this.nameProperty
}, { tandem: Tandem.OPT_OUT } );
}
else {
this.descriptionContent = simScreenStringProperty; // fall back on generic name
this.screenButtonsHelpText = simScreenStringProperty; // fall back on generic name
}

assert && this.activeProperty.lazyLink( () => {
Expand Down

0 comments on commit e3366b8

Please sign in to comment.