Skip to content

Commit

Permalink
apply StringUtils.wrapLTR to solute and solution formulas, to preserv…
Browse files Browse the repository at this point in the history
…e left-to-right order, #326
  • Loading branch information
pixelzoom committed Feb 8, 2023
1 parent f55779a commit 6a80c6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion js/beerslaw/view/SolutionControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ function createItem( solution: BeersLawSolution ): ComboBoxItem<BeersLawSolution

const labelStringProperty = new DerivedProperty(
[ BeersLawLabStrings.pattern[ '0formula' ][ '1nameStringProperty' ], solution.nameProperty, solution.formulaProperty ],
( pattern, name, formula ) => ( formula === null || formula === '' ) ? name : StringUtils.format( pattern, formula, name )
( pattern, name, formula ) => {
if ( formula === null || formula === '' ) {
return name; // if there is no formula, default to the solution name
}
else {
// See https://github.com/phetsims/beers-law-lab/issues/326 for StringUtils.wrapLTR
return StringUtils.format( pattern, StringUtils.wrapLTR( formula ), name );
}
}
);

const labelText = new RichText( labelStringProperty, {
Expand Down
3 changes: 2 additions & 1 deletion js/concentration/view/ConcentrationScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import SolutionVolumeNode from './SolutionVolumeNode.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import StringIO from '../../../../tandem/js/types/StringIO.js';
import StringUtils from '../../../../phetcommon/js/util/StringUtils.js';

export default class ConcentrationScreenView extends ScreenView {

Expand Down Expand Up @@ -79,7 +80,7 @@ export default class ConcentrationScreenView extends ScreenView {
const solute = model.shaker.soluteProperty.value;
const formula = solute.formulaProperty.value;
const name = solute.nameProperty.value;
return formula ? formula : name;
return formula ? StringUtils.wrapLTR( formula ) : name;
}, {
tandem: tandem.createTandem( 'soluteLabelStringProperty' ),
phetioValueType: StringIO,
Expand Down

0 comments on commit 6a80c6d

Please sign in to comment.