This repository was archived by the owner on Feb 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
ReservationUnits/ReservationUnitEditor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ function SortedSelect<T>(
1212 const opts = [ ...originalOptions ] ;
1313 if ( props . sort ) {
1414 opts . sort ( ( a , b ) =>
15- a . label . toLowerCase ( ) . localeCompare ( b . label . toLowerCase ( ) )
15+ a . label && b . label
16+ ? a . label . toLowerCase ( ) . localeCompare ( b . label . toLowerCase ( ) )
17+ : ! a . label
18+ ? 1
19+ : - 1
1620 ) ;
1721 }
1822 return opts ;
Original file line number Diff line number Diff line change @@ -294,10 +294,13 @@ const Events = ({
294294) ;
295295
296296const sortByDraftStatusAndTitle = ( resources : Resource [ ] ) => {
297- return resources . sort (
298- ( a , b ) =>
299- Number ( a . isDraft ) - Number ( b . isDraft ) || a . title . localeCompare ( b . title )
300- ) ;
297+ return resources . sort ( ( a , b ) => {
298+ const draftComparison = Number ( a . isDraft ) - Number ( b . isDraft ) ;
299+ const titleComparison =
300+ a . title && b . title ? a . title . localeCompare ( b . title ) : ! a . title ? 1 : - 1 ;
301+
302+ return draftComparison || titleComparison ;
303+ } ) ;
301304} ;
302305
303306const ResourceCalendar = ( { resources } : Props ) : JSX . Element => {
You can’t perform that action at this time.
0 commit comments