@@ -1947,7 +1947,44 @@ describe('Select.Basic', () => {
1947
1947
'Communicated' ,
1948
1948
) ;
1949
1949
} ) ;
1950
-
1950
+ it ( 'filterSort should work with search value when grouping' , ( ) => {
1951
+ const { container } = render (
1952
+ < Select
1953
+ open
1954
+ showSearch
1955
+ searchValue = "entry"
1956
+ style = { { width : 100 } }
1957
+ placeholder = "Search to Select"
1958
+ optionFilterProp = "label"
1959
+ filterSort = {
1960
+ ( optionA , optionB , info ) => {
1961
+ if ( ! info . searchValue ) return 0 ;
1962
+ const labelA = ( optionA ?. label ?? '' ) . toLowerCase ( ) ;
1963
+ const labelB = ( optionB ?. label ?? '' ) . toLowerCase ( ) ;
1964
+ const matchA = labelA . startsWith ( info . searchValue ) ;
1965
+ const matchB = labelB . startsWith ( info . searchValue ) ;
1966
+ if ( matchA && ! matchB ) return - 1 ;
1967
+ if ( ! matchA && matchB ) return 1 ;
1968
+ return labelA . localeCompare ( labelB ) ;
1969
+ } }
1970
+ options = { [
1971
+ {
1972
+ value : 'group1' ,
1973
+ label : 'group1' ,
1974
+ options : [
1975
+ { label : 'Entry1' , value : 'Entry1' } ,
1976
+ { label : 'Entry2' , value : 'Entry2' } ,
1977
+ { label : 'Entry3' , value : 'Entry3' } ,
1978
+ { label : 'Entry' , value : 'Entry' } ,
1979
+ ] ,
1980
+ } ,
1981
+ ] }
1982
+ /> ,
1983
+ ) ;
1984
+ expect ( container . querySelector ( '.rc-select-item-option-grouped' ) . textContent ) . toBe (
1985
+ 'Entry' ,
1986
+ ) ;
1987
+ } )
1951
1988
it ( 'correctly handles the `tabIndex` prop' , ( ) => {
1952
1989
const { container } = render ( < Select tabIndex = { 0 } /> ) ;
1953
1990
expect ( container . querySelector ( '.rc-select' ) . getAttribute ( 'tabindex' ) ) . toBeFalsy ( ) ;
0 commit comments