File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed
src/Components/CreateImageWizard/steps/Timezone/components Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -56,24 +56,17 @@ const TimezoneDropDown = () => {
5656 }
5757 } ;
5858
59+ const normalizeTimezoneString = ( value : string ) : string =>
60+ value . toLowerCase ( ) . replace ( / [ _ / ] / g, ' ' ) . replace ( / \s + / g, ' ' ) . trim ( ) ;
61+
5962 const sortedTimezones = useMemo ( ( ) => {
60- let filtered = timezones ;
61-
62- if ( searchValue ) {
63- const normalizedFilter = searchValue
64- . toLowerCase ( )
65- . replace ( / [ _ / ] / g, ' ' )
66- . replace ( / \s + / g, ' ' )
67- . trim ( ) ;
68-
69- filtered = timezones . filter ( ( tz ) => {
70- const normalizedTimezone = tz
71- . toLowerCase ( )
72- . replace ( / [ _ / ] / g, ' ' )
73- . replace ( / \s + / g, ' ' ) ;
74- return normalizedTimezone . includes ( normalizedFilter ) ;
75- } ) ;
76- }
63+ const normalizedFilter = normalizeTimezoneString ( searchValue ) ;
64+
65+ const filtered = normalizedFilter
66+ ? timezones . filter ( ( tz ) =>
67+ normalizeTimezoneString ( tz ) . includes ( normalizedFilter ) ,
68+ )
69+ : timezones ;
7770
7871 return [ ...filtered ] . sort ( ( a , b ) => {
7972 if ( a === DEFAULT_TIMEZONE ) return - 1 ;
You can’t perform that action at this time.
0 commit comments