|
55 | 55 | </span>
|
56 | 56 | </div>
|
57 | 57 | <transition name="multiselect">
|
58 |
| - <ul |
59 |
| - :style="{ maxHeight: maxHeight + 'px' }" |
60 |
| - ref="list" |
| 58 | + <div |
| 59 | + class="multiselect__content-wrapper" |
61 | 60 | v-show="isOpen"
|
62 | 61 | @mousedown.prevent
|
63 |
| - class="multiselect__content"> |
64 |
| - <slot name="beforeList"></slot> |
65 |
| - <li v-if="multiple && max === internalValue.length"> |
66 |
| - <span class="multiselect__option"> |
67 |
| - <slot name="maxElements">Maximum of {{ max }} options selected. First remove a selected option to select another.</slot> |
68 |
| - </span> |
69 |
| - </li> |
70 |
| - <template v-if="!max || internalValue.length < max"> |
71 |
| - <li class="multiselect__element" v-for="(option, index) of filteredOptions" :key="index"> |
72 |
| - <span |
73 |
| - tabindex="0" |
74 |
| - v-if="!(option && option.$isLabel)" |
75 |
| - :class="optionHighlight(index, option)" |
76 |
| - @mousedown.prevent="select(option)" |
77 |
| - @mouseenter="pointerSet(index)" |
78 |
| - :data-select="option && option.isTag ? tagPlaceholder : selectLabelText" |
79 |
| - :data-selected="selectedLabelText" |
80 |
| - :data-deselect="deselectLabelText" |
81 |
| - class="multiselect__option"> |
82 |
| - <slot name="option" :option="option" :search="search"> |
83 |
| - <span>{{ getOptionLabel(option) }}</span> |
84 |
| - </slot> |
| 62 | + :style="{ maxHeight: maxHeight + 'px' }" |
| 63 | + ref="list"> |
| 64 | + <ul class="multiselect__content" :style="contentStyle"> |
| 65 | + <slot name="beforeList"></slot> |
| 66 | + <li v-if="multiple && max === internalValue.length"> |
| 67 | + <span class="multiselect__option"> |
| 68 | + <slot name="maxElements">Maximum of {{ max }} options selected. First remove a selected option to select another.</slot> |
85 | 69 | </span>
|
86 |
| - <span |
87 |
| - v-if="option && option.$isLabel" |
88 |
| - :class="optionHighlight(index, option)" |
89 |
| - class="multiselect__option multiselect__option--disabled"> |
90 |
| - {{ option.$groupLabel }} |
| 70 | + </li> |
| 71 | + <template v-if="!max || internalValue.length < max"> |
| 72 | + <li class="multiselect__element" v-for="(option, index) of filteredOptions" :key="index"> |
| 73 | + <span |
| 74 | + tabindex="0" |
| 75 | + v-if="!(option && option.$isLabel)" |
| 76 | + :class="optionHighlight(index, option)" |
| 77 | + @mousedown.prevent="select(option)" |
| 78 | + @mouseenter="pointerSet(index)" |
| 79 | + :data-select="option && option.isTag ? tagPlaceholder : selectLabelText" |
| 80 | + :data-selected="selectedLabelText" |
| 81 | + :data-deselect="deselectLabelText" |
| 82 | + class="multiselect__option"> |
| 83 | + <slot name="option" :option="option" :search="search"> |
| 84 | + <span>{{ getOptionLabel(option) }}</span> |
| 85 | + </slot> |
| 86 | + </span> |
| 87 | + <span |
| 88 | + v-if="option && option.$isLabel" |
| 89 | + :class="optionHighlight(index, option)" |
| 90 | + class="multiselect__option multiselect__option--disabled"> |
| 91 | + {{ option.$groupLabel }} |
| 92 | + </span> |
| 93 | + </li> |
| 94 | + </template> |
| 95 | + <li v-show="filteredOptions.length === 0 && search && !loading"> |
| 96 | + <span class="multiselect__option"> |
| 97 | + <slot name="noResult">No elements found. Consider changing the search query.</slot> |
91 | 98 | </span>
|
92 | 99 | </li>
|
93 |
| - </template> |
94 |
| - <li v-show="filteredOptions.length === 0 && search && !loading"> |
95 |
| - <span class="multiselect__option"> |
96 |
| - <slot name="noResult">No elements found. Consider changing the search query.</slot> |
97 |
| - </span> |
98 |
| - </li> |
99 |
| - <slot name="afterList"></slot> |
100 |
| - </ul> |
| 100 | + <slot name="afterList"></slot> |
| 101 | + </ul> |
| 102 | + </div> |
101 | 103 | </transition>
|
102 | 104 | </div>
|
103 | 105 | </template>
|
|
238 | 240 | if (this.multiple && this.value && this.value.length) {
|
239 | 241 | return this.isOpen ? { 'width': 'auto' } : { 'display': 'none' }
|
240 | 242 | }
|
| 243 | + }, |
| 244 | + contentStyle () { |
| 245 | + return this.options.length |
| 246 | + ? { 'display': 'inline-block' } |
| 247 | + : { 'display': 'block' } |
241 | 248 | }
|
242 | 249 | }
|
243 | 250 | }
|
@@ -499,23 +506,28 @@ fieldset[disabled] .multiselect {
|
499 | 506 | display: none;
|
500 | 507 | }
|
501 | 508 |
|
502 |
| -.multiselect__content { |
| 509 | +.multiselect__content-wrapper { |
503 | 510 | position: absolute;
|
504 |
| - list-style: none; |
505 | 511 | display: block;
|
506 | 512 | background: #fff;
|
507 | 513 | width: 100%;
|
508 | 514 | max-height: 240px;
|
509 | 515 | overflow: auto;
|
510 |
| - padding: 0; |
511 |
| - margin: 0; |
512 | 516 | border: 1px solid #E8E8E8;
|
513 | 517 | border-top: none;
|
514 | 518 | border-bottom-left-radius: 5px;
|
515 | 519 | border-bottom-right-radius: 5px;
|
516 | 520 | z-index: 50;
|
517 | 521 | }
|
518 | 522 |
|
| 523 | +.multiselect__content { |
| 524 | + list-style: none; |
| 525 | + display: inline-block; |
| 526 | + padding: 0; |
| 527 | + margin: 0; |
| 528 | + min-width: 100%; |
| 529 | +} |
| 530 | +
|
519 | 531 | .multiselect--above .multiselect__content {
|
520 | 532 | bottom: 100%;
|
521 | 533 | border-bottom-left-radius: 0;
|
|
0 commit comments