Skip to content

Commit

Permalink
fix(VAutocomplete): show selections slot and the input side-by-side l…
Browse files Browse the repository at this point in the history
…ike v2 does (#15768)

fixes #15756
  • Loading branch information
yuwu9145 committed Oct 13, 2022
1 parent 073eca7 commit 198c009
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -90,5 +90,10 @@
opacity: 0

.v-field--focused
.v-autocomplete__selection
.v-autocomplete__selection-text
opacity: 0

&--selection-slot
&.v-text-field input
position: relative
padding-inline-start: 0
Expand Up @@ -178,7 +178,10 @@ export const VAutocomplete = genericComponent<new <

isSelecting.value = true

search.value = item.title
if (!slots.selection) {
search.value = item.title
}

menu.value = false
isPristine.value = true

Expand All @@ -189,7 +192,7 @@ export const VAutocomplete = genericComponent<new <
watch(isFocused, val => {
if (val) {
isSelecting.value = true
search.value = props.multiple ? '' : String(selections.value.at(-1)?.props.title ?? '')
search.value = props.multiple || !!slots.selection ? '' : String(selections.value.at(-1)?.props.title ?? '')
isPristine.value = true

nextTick(() => isSelecting.value = false)
Expand Down Expand Up @@ -224,6 +227,7 @@ export const VAutocomplete = genericComponent<new <
'v-autocomplete--active-menu': menu.value,
'v-autocomplete--chips': !!props.chips,
[`v-autocomplete--${props.multiple ? 'multiple' : 'single'}`]: true,
'v-autocomplete--selection-slot': !!slots.selection,
},
]}
appendInnerIcon={ props.menuIcon }
Expand Down

0 comments on commit 198c009

Please sign in to comment.