Skip to content

Commit

Permalink
support dynamic locale for voicing name responses, phetsims/ratio-and…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Nov 23, 2022
1 parent b4196d2 commit ddb0240
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions js/ComboBoxButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { Shape } from '../../kite/js/imports.js';
import optionize from '../../phet-core/js/optionize.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import { AriaHasPopUpMutator, GridBox, Line, Node, Path, PDOMBehaviorFunction, PDOMPeer, TPaint } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import ButtonNode from './buttons/ButtonNode.js';
Expand All @@ -23,6 +22,8 @@ import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import ComboBox, { ComboBoxItem } from './ComboBox.js';
import Multilink from '../../axon/js/Multilink.js';
import TReadOnlyProperty from '../../axon/js/TReadOnlyProperty.js';
import PatternStringProperty from '../../axon/js/PatternStringProperty.js';
import Property from '../../axon/js/Property.js';

// constants
const ALIGN_VALUES = [ 'left', 'center', 'right' ] as const;
Expand Down Expand Up @@ -243,7 +244,10 @@ export default class ComboBoxButton<T> extends RectangularPushButton {

// pdom
this.innerContent = ( item.a11yLabel || null );
this.voicingNameResponse = StringUtils.fillIn( options.comboBoxVoicingNameResponsePattern, {
const patternProperty = typeof options.comboBoxVoicingNameResponsePattern === 'string' ?
new Property( options.comboBoxVoicingNameResponsePattern ) :
options.comboBoxVoicingNameResponsePattern;
this.voicingNameResponse = new PatternStringProperty( patternProperty, {
value: item.a11yLabel
} );
};
Expand Down
10 changes: 7 additions & 3 deletions js/ComboBoxListItemNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import { Shape } from '../../kite/js/imports.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import optionize from '../../phet-core/js/optionize.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import { IndexedNodeIO, TPaint, Node, NodeOptions, Rectangle, Voicing, VoicingOptions } from '../../scenery/js/imports.js';
import { IndexedNodeIO, Node, NodeOptions, Rectangle, TPaint, Voicing, VoicingOptions } from '../../scenery/js/imports.js';
import Tandem from '../../tandem/js/Tandem.js';
import sun from './sun.js';
import SunConstants from './SunConstants.js';
import { ComboBoxItem } from './ComboBox.js';
import TReadOnlyProperty from '../../axon/js/TReadOnlyProperty.js';
import Property from '../../axon/js/Property.js';
import PatternStringProperty from '../../axon/js/PatternStringProperty.js';

type SelfOptions = {
align?: 'left' | 'right' | 'center';
Expand Down Expand Up @@ -94,7 +95,10 @@ export default class ComboBoxListItemNode<T> extends Voicing( Node ) {
// pdom: get innerContent from the item
options.innerContent = ( item.a11yLabel || null );
options.voicingObjectResponse = ( item.a11yLabel || null );
options.voicingNameResponse = StringUtils.fillIn( options.comboBoxVoicingNameResponsePattern, {
const patternProperty = typeof options.comboBoxVoicingNameResponsePattern === 'string' ?
new Property( options.comboBoxVoicingNameResponsePattern ) :
options.comboBoxVoicingNameResponsePattern;
options.voicingNameResponse = new PatternStringProperty( patternProperty, {
value: item.a11yLabel
} );

Expand Down

0 comments on commit ddb0240

Please sign in to comment.