@@ -8,7 +8,7 @@ import type {
88} from '../Select' ;
99import { injectPropsWithOption } from '../utils/valueUtil' ;
1010import type { Ref } from 'vue' ;
11- import { computed } from 'vue' ;
11+ import { toRaw , computed } from 'vue' ;
1212
1313function includes ( test : any , search : string ) {
1414 return toArray ( test ) . join ( '' ) . toUpperCase ( ) . includes ( search ) ;
@@ -22,22 +22,24 @@ export default (
2222 optionFilterProp ?: Ref < string > ,
2323) =>
2424 computed ( ( ) => {
25- if ( ! searchValue . value || filterOption . value === false ) {
25+ const searchValueVal = searchValue . value ;
26+ const optionFilterPropValue = optionFilterProp ?. value ;
27+ const filterOptionValue = filterOption ?. value ;
28+ if ( ! searchValueVal || filterOptionValue === false ) {
2629 return options . value ;
2730 }
28-
2931 const { options : fieldOptions , label : fieldLabel , value : fieldValue } = fieldNames . value ;
3032 const filteredOptions : DefaultOptionType [ ] = [ ] ;
3133
32- const customizeFilter = typeof filterOption . value === 'function' ;
34+ const customizeFilter = typeof filterOptionValue === 'function' ;
3335
34- const upperSearch = searchValue . value . toUpperCase ( ) ;
36+ const upperSearch = searchValueVal . toUpperCase ( ) ;
3537 const filterFunc = customizeFilter
36- ? ( filterOption . value as FilterFunc < BaseOptionType > )
38+ ? ( filterOptionValue as FilterFunc < BaseOptionType > )
3739 : ( _ : string , option : DefaultOptionType ) => {
3840 // Use provided `optionFilterProp`
39- if ( optionFilterProp . value ) {
40- return includes ( option [ optionFilterProp . value ] , upperSearch ) ;
41+ if ( optionFilterPropValue ) {
42+ return includes ( option [ optionFilterPropValue ] , upperSearch ) ;
4143 }
4244
4345 // Auto select `label` or `value` by option type
@@ -53,17 +55,17 @@ export default (
5355 ? opt => injectPropsWithOption ( opt )
5456 : opt => opt ;
5557
56- options . value . forEach ( item => {
58+ toRaw ( options . value ) . forEach ( item => {
5759 // Group should check child options
5860 if ( item [ fieldOptions ] ) {
5961 // Check group first
60- const matchGroup = filterFunc ( searchValue . value , wrapOption ( item ) ) ;
62+ const matchGroup = filterFunc ( searchValueVal , wrapOption ( item ) ) ;
6163 if ( matchGroup ) {
6264 filteredOptions . push ( item ) ;
6365 } else {
6466 // Check option
6567 const subOptions = item [ fieldOptions ] . filter ( ( subItem : DefaultOptionType ) =>
66- filterFunc ( searchValue . value , wrapOption ( subItem ) ) ,
68+ filterFunc ( searchValueVal , wrapOption ( subItem ) ) ,
6769 ) ;
6870 if ( subOptions . length ) {
6971 filteredOptions . push ( {
@@ -76,10 +78,9 @@ export default (
7678 return ;
7779 }
7880
79- if ( filterFunc ( searchValue . value , wrapOption ( item ) ) ) {
81+ if ( filterFunc ( searchValueVal , wrapOption ( item ) ) ) {
8082 filteredOptions . push ( item ) ;
8183 }
8284 } ) ;
83-
8485 return filteredOptions ;
8586 } ) ;
0 commit comments