fix: multi select width bug (#303)
* fix: multi select width bug * style: truncate multi-select values text --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
ef83ffcf77
commit
8321bd38db
|
@ -5,7 +5,6 @@
|
|||
<template #label>
|
||||
<slot name="label" />
|
||||
</template>
|
||||
|
||||
<v-select v-model="compVal"
|
||||
:data="finalOptions"
|
||||
:label="label"
|
||||
|
@ -26,14 +25,14 @@
|
|||
:help-position="helpPosition"
|
||||
|
||||
@update-options="updateOptions"
|
||||
@update:model-value="updateModelValue"
|
||||
>
|
||||
<template #selected="{option}">
|
||||
<slot name="selected" :option="option" :optionName="getOptionName(option)">
|
||||
<template v-if="multiple">
|
||||
<div class="flex items-center truncate mr-6">
|
||||
<span v-for="(item,index) in option" :key="item" class="truncate">
|
||||
<span v-if="index!==0">, </span>
|
||||
{{ getOptionName(item) }}
|
||||
<span class="truncate">
|
||||
{{ selectedValues.join(', ') }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -104,7 +103,8 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
additionalOptions: []
|
||||
additionalOptions: [],
|
||||
selectedValues:[],
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -121,6 +121,9 @@ export default {
|
|||
if (option) return option[this.displayKey]
|
||||
return null
|
||||
},
|
||||
updateModelValue(newValues){
|
||||
this.selectedValues = newValues
|
||||
},
|
||||
updateOptions (newItem) {
|
||||
if (newItem) {
|
||||
this.additionalOptions.push(newItem)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="v-select relative" ref="select">
|
||||
<div class="v-select relative" :class="[{'w-0': multiple, 'min-w-full':multiple}]" ref="select">
|
||||
<span class="inline-block w-full rounded-md">
|
||||
<button type="button" aria-haspopup="listbox" aria-expanded="true" aria-labelledby="listbox-label"
|
||||
class="cursor-pointer"
|
||||
|
|
Loading…
Reference in New Issue