@@ -2,7 +2,11 @@ import PropTypes from 'prop-types';
22import React from 'react' ;
33import { connect } from 'react-redux' ;
44
5- import { caseInsensitiveSubmatch , compareString } from '@togglecorp/fujs' ;
5+ import {
6+ caseInsensitiveSubmatch ,
7+ compareString ,
8+ compareStringSearch ,
9+ } from '@togglecorp/fujs' ;
610import AccentButton from '#rsca/Button/AccentButton' ;
711import SearchInput from '#rsci/SearchInput' ;
812import RadioInput from '#rsci/RadioInput' ;
@@ -110,9 +114,9 @@ export default class ProjectRegions extends React.PureComponent {
110114
111115 if ( this . props . projectDetails !== projectDetails ) {
112116 const { regions = [ ] } = projectDetails ;
113- const displayRegionList = regions . filter (
114- region => caseInsensitiveSubmatch ( region . title , searchInputValue ) ,
115- ) ;
117+ const displayRegionList = regions
118+ . filter ( region => caseInsensitiveSubmatch ( region . title , searchInputValue ) )
119+ . sort ( ( a , b ) => compareStringSearch ( a . title , b . title , searchInputValue ) ) ;
116120
117121 let newSelectedRegion = selectedRegion ;
118122 if ( regions . findIndex ( r => r . id === selectedRegion ) === - 1 ) {
@@ -151,9 +155,9 @@ export default class ProjectRegions extends React.PureComponent {
151155 handleSearchInputChange = ( searchInputValue ) => {
152156 const { projectDetails } = this . props ;
153157 const { regions = [ ] } = projectDetails ;
154- const displayRegionList = regions . filter (
155- region => caseInsensitiveSubmatch ( region . title , searchInputValue ) ,
156- ) ;
158+ const displayRegionList = regions
159+ . filter ( region => caseInsensitiveSubmatch ( region . title , searchInputValue ) )
160+ . sort ( ( a , b ) => compareStringSearch ( a . title , b . title , searchInputValue ) ) ;
157161
158162 this . setState ( {
159163 displayRegionList,
0 commit comments