@@ -9,13 +9,13 @@ const defaultFilter: ShowSearchType['filter'] = (search, options, { label = '' }
99const defaultRender : ShowSearchType [ 'render' ] = ( inputValue , path , prefixCls , fieldNames ) =>
1010 path . map ( opt => opt [ fieldNames . label as string ] ) . join ( ' / ' ) ;
1111
12- export default (
12+ const useSearchOptions = (
1313 search : string ,
1414 options : DefaultOptionType [ ] ,
1515 fieldNames : InternalFieldNames ,
1616 prefixCls : string ,
1717 config : ShowSearchType ,
18- changeOnSelect ?: boolean ,
18+ enableHalfPath ?: boolean ,
1919) => {
2020 const { filter = defaultFilter , render = defaultRender , limit = 50 , sort } = config ;
2121
@@ -46,8 +46,8 @@ export default (
4646 // If is leaf option
4747 ! children ||
4848 children . length === 0 ||
49- // If is changeOnSelect
50- changeOnSelect
49+ // If is changeOnSelect or multiple
50+ enableHalfPath
5151 ) {
5252 if ( filter ( search , connectedPathOptions , { label : fieldNames . label } ) ) {
5353 filteredOptions . push ( {
@@ -87,5 +87,7 @@ export default (
8787 return limit !== false && limit > 0
8888 ? filteredOptions . slice ( 0 , limit as number )
8989 : filteredOptions ;
90- } , [ search , options , fieldNames , prefixCls , render , changeOnSelect , filter , sort , limit ] ) ;
90+ } , [ search , options , fieldNames , prefixCls , render , enableHalfPath , filter , sort , limit ] ) ;
9191} ;
92+
93+ export default useSearchOptions ;
0 commit comments