Skip to content

Commit

Permalink
Fixing regionAndCulture display sorting so it puts the "default" firs…
Browse files Browse the repository at this point in the history
…t, and adding locale-specific sort, see #953
  • Loading branch information
jonathanolson committed Feb 28, 2024
1 parent daaa2d9 commit 82a9de3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion js/preferences/RegionAndCultureComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@ class RegionAndCultureComboBox extends ComboBox<RegionAndCulture> {
tandem: Tandem.OPT_OUT // We don't want to instrument components for preferences, https://github.com/phetsims/joist/issues/744#issuecomment-1196028362
}, providedOptions );

const comboBoxItems = availableRuntimeRegionAndCultures.map( regionAndCulture => {
// Sort the available region and culture options, with the default (initially loaded) region and culture at the top.
const localeCompare = new Intl.Collator( phet.chipper.locale ).compare;
const comboBoxItems = availableRuntimeRegionAndCultures.sort( ( a, b ) => {
if ( a === phet.chipper.regionAndCulture ) {
return -1;
}
else if ( b === phet.chipper.regionAndCulture ) {
return 1;
}
else {
return localeCompare( regionAndCultureStringPropertyMap[ a ].value, regionAndCultureStringPropertyMap[ b ].value );
}
} ).map( regionAndCulture => {

return {
value: regionAndCulture,
Expand Down

0 comments on commit 82a9de3

Please sign in to comment.