File tree Expand file tree Collapse file tree
packages/browser-sdk/src/toolbar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,11 +25,24 @@ export function FeaturesTable({
2525 . toLocaleLowerCase ( )
2626 . includes ( searchQuery ?. toLocaleLowerCase ( ) ?? "" ) ,
2727 ) ;
28- // List features that match the search query first
28+
29+ // List features that match the search query first then alphabetically
2930 const searchedFeatures =
3031 searchQuery === null
3132 ? features
32- : [ ...features ] . sort ( ( a , _b ) => ( a . key . includes ( searchQuery ) ? - 1 : 1 ) ) ;
33+ : [ ...features ] . sort ( ( a , b ) => {
34+ const aMatches = a . key . includes ( searchQuery ) ;
35+ const bMatches = b . key . includes ( searchQuery ) ;
36+
37+ // If both match or both don't match, sort alphabetically
38+ if ( aMatches === bMatches ) {
39+ return a . key . localeCompare ( b . key ) ;
40+ }
41+
42+ // Otherwise, matching features come first
43+ return aMatches ? - 1 : 1 ;
44+ } ) ;
45+
3346 return (
3447 < table class = "features-table" style = { { "--n" : searchedFeatures . length } } >
3548 < tbody >
You can’t perform that action at this time.
0 commit comments