@@ -1948,6 +1948,42 @@ describe('Select.Basic', () => {
19481948 ) ;
19491949 } ) ;
19501950
1951+ it ( 'filterSort should work with search value when grouping' , ( ) => {
1952+ const { container } = render (
1953+ < Select
1954+ open
1955+ showSearch
1956+ searchValue = "entry"
1957+ style = { { width : 100 } }
1958+ placeholder = "Search to Select"
1959+ optionFilterProp = "label"
1960+ filterSort = { ( 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 ( 'Entry' ) ;
1985+ } ) ;
1986+
19511987 it ( 'correctly handles the `tabIndex` prop' , ( ) => {
19521988 const { container } = render ( < Select tabIndex = { 0 } /> ) ;
19531989 expect ( container . querySelector ( '.rc-select' ) . getAttribute ( 'tabindex' ) ) . toBeFalsy ( ) ;
0 commit comments