@@ -64,7 +64,7 @@ export function PlatformSelector({
6464 const [ open , setOpen ] = useState ( false ) ;
6565 const [ searchValue , setSearchValue ] = useState ( '' ) ;
6666 const debounceRef = useRef < NodeJS . Timeout > ( ) ;
67-
67+
6868 // Debounced search handler to prevent rapid re-renders
6969 const debouncedSetSearchValue = useCallback ( ( value : string ) => {
7070 if ( debounceRef . current ) {
@@ -77,24 +77,24 @@ export function PlatformSelector({
7777 if ( ! searchValue ) {
7878 return platformsAndGuides ;
7979 }
80-
80+
8181 // Find currently selected platform first to ensure it's never filtered out
8282 const selectedPlatform = platformsAndGuides . find (
8383 lang => lang . key === currentPlatformKey
8484 ) ;
85-
85+
8686 // Filter out the selected platform from search, then add it back at the end
8787 const otherPlatforms = platformsAndGuides . filter (
8888 lang => lang . key !== currentPlatformKey
8989 ) ;
90-
90+
9191 // any of these fields can be used to match the search value
9292 const keys = [ 'title' , 'name' , 'aliases' , 'sdk' , 'keywords' ] ;
9393 const matches_ = matchSorter ( otherPlatforms , searchValue , {
9494 keys,
9595 threshold : matchSorter . rankings . ACRONYM ,
9696 } ) ;
97-
97+
9898 // Always include the selected platform at the beginning
9999 return selectedPlatform ? [ selectedPlatform , ...matches_ ] : matches_ ;
100100 } , [ searchValue , currentPlatformKey , platformsAndGuides ] ) ;
@@ -131,7 +131,7 @@ export function PlatformSelector({
131131 setStoredPlatformKey ( localStorage . getItem ( 'active-platform' ) ) ;
132132 }
133133 } , [ currentPlatformKey ] ) ;
134-
134+
135135 // Cleanup debounce timer on unmount
136136 useEffect ( ( ) => {
137137 return ( ) => {
0 commit comments