@@ -277,6 +277,11 @@ const getOptionOfSetSelected = ({ api, props }) => {
277277 option . state = { }
278278 }
279279
280+ // 如果 option 有 currentLabel 但没有设置到 state 中,则复制过去
281+ if ( option . currentLabel !== undefined && option . state . currentLabel === undefined ) {
282+ option . state . currentLabel = option . currentLabel
283+ }
284+
280285 if ( option . created ) {
281286 option . createdLabel = option . state . currentLabel
282287 option . createdSelected = true
@@ -285,7 +290,7 @@ const getOptionOfSetSelected = ({ api, props }) => {
285290 }
286291
287292 // tiny 新增
288- if ( ! option . state . currentLabel ) {
293+ if ( ! option . state . currentLabel && ! option . currentLabel ) {
289294 api . clearNoMatchValue ( '' )
290295 }
291296
@@ -301,7 +306,8 @@ const getResultOfSetSelected = ({ state, api, props }) => {
301306 state . modelValue . forEach ( ( value ) => {
302307 // tiny 新增
303308 const option = api . getOption ( value )
304- if ( ! props . clearNoMatchValue || ( props . clearNoMatchValue && option . label ) ) {
309+ const hasLabel = option ?. label || option ?. currentLabel || ( option ?. state && option . state . currentLabel )
310+ if ( ! props . clearNoMatchValue || ( props . clearNoMatchValue && hasLabel ) ) {
305311 result . push ( option )
306312 newModelValue . push ( value )
307313 }
@@ -321,6 +327,10 @@ export const setSelected =
321327 state . selected = option
322328 state . selectedLabel = option . state . currentLabel || option . currentLabel
323329 ; ( props . filterable || props . searchable ) && ! props . shape && ( state . query = state . selectedLabel )
330+ // 使用 panel 插槽且有选中值时,不显示 placeholder
331+ if ( vm . $slots . panel && state . selectedLabel && ( props . filterable || props . searchable ) ) {
332+ state . currentPlaceholder = ''
333+ }
324334 } else {
325335 const result = getResultOfSetSelected ( { state, props, api } )
326336 state . selectCls = result . length
@@ -334,6 +344,11 @@ export const setSelected =
334344 }
335345 state . selected . length && ( state . selectedLabel = '' )
336346
347+ // 使用 panel 插槽且有选中值时,不显示 placeholder
348+ if ( vm . $slots . panel && result . length > 0 && ( props . filterable || props . searchable ) ) {
349+ state . currentPlaceholder = ''
350+ }
351+
337352 state . tips = state . selected . map ( ( item ) => ( item . state ? item . state . currentLabel : item . currentLabel ) ) . join ( ',' )
338353
339354 setFilteredSelectCls ( nextTick , state , props )
@@ -1121,7 +1136,10 @@ export const watchValue =
11211136 if ( props . multiple ) {
11221137 api . resetInputHeight ( )
11231138
1124- if ( ( value && value . length > 0 ) || ( vm . $refs . input && state . query !== '' ) ) {
1139+ // 使用 panel 插槽且有选中值时,不显示 placeholder
1140+ if ( vm . $slots . panel && value && value . length > 0 ) {
1141+ state . currentPlaceholder = ''
1142+ } else if ( ( value && value . length > 0 ) || ( vm . $refs . input && state . query !== '' ) ) {
11251143 state . currentPlaceholder = ''
11261144 } else {
11271145 state . currentPlaceholder = state . cachedPlaceHolder
@@ -1196,7 +1214,7 @@ export const calcOverFlow =
11961214 }
11971215 }
11981216
1199- const postOperOfToVisible = ( { props, state, constants } ) => {
1217+ const postOperOfToVisible = ( { props, state, constants, vm } ) => {
12001218 if ( props . multiple ) {
12011219 if ( props . modelValue && props . modelValue . length && props . initLabel && ! state . selected . length ) {
12021220 state . selectedLabel = props . initLabel
@@ -1219,8 +1237,13 @@ const postOperOfToVisible = ({ props, state, constants }) => {
12191237 }
12201238 }
12211239
1240+ // 使用 panel 插槽且有选中值时,不显示 placeholder
12221241 if ( props . filterable || props . searchable ) {
1223- state . currentPlaceholder = state . cachedPlaceHolder
1242+ if ( vm . $slots . panel && state . selectedLabel ) {
1243+ state . currentPlaceholder = ''
1244+ } else {
1245+ state . currentPlaceholder = state . cachedPlaceHolder
1246+ }
12241247 }
12251248
12261249 if ( props . modelValue && props . initLabel && ! state . selectedLabel ) {
@@ -1255,7 +1278,7 @@ export const toVisible =
12551278 }
12561279 } )
12571280
1258- postOperOfToVisible ( { props, state, constants } )
1281+ postOperOfToVisible ( { props, state, constants, vm } )
12591282 }
12601283
12611284export const toHide =
0 commit comments