Fixed #2525 - empty slot for Autocomplete
parent
0ae83cd791
commit
8bc2c630e5
|
@ -387,11 +387,15 @@ const AutoCompleteSlots = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'content',
|
name: 'content',
|
||||||
description: 'Custom content for the virtual scroller'
|
description: 'Custom content for the virtual scroller.'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'loader',
|
name: 'loader',
|
||||||
description: 'Custom content for the virtual scroller loader items'
|
description: 'Custom content for the virtual scroller loader items.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'empty',
|
||||||
|
description: 'Custom empty template when there is no data to display.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,10 @@ export interface AutoCompleteSlots {
|
||||||
*/
|
*/
|
||||||
options: any[];
|
options: any[];
|
||||||
}) => VNode[];
|
}) => VNode[];
|
||||||
|
/**
|
||||||
|
* Custom empty template when there is no data to display.
|
||||||
|
*/
|
||||||
|
empty: () => VNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare type AutoCompleteEmits = {
|
export declare type AutoCompleteEmits = {
|
||||||
|
|
|
@ -119,6 +119,9 @@
|
||||||
<!--TODO: Deprecated since v3.16.0-->
|
<!--TODO: Deprecated since v3.16.0-->
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
<li v-if="!items || (items && items.length === 0)" class="p-autocomplete-empty-message" role="option">
|
||||||
|
<slot name="empty">{{ searchResultMessageText }}</slot>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="$slots.loader" v-slot:loader="{ options }">
|
<template v-if="$slots.loader" v-slot:loader="{ options }">
|
||||||
|
@ -323,7 +326,7 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
suggestions() {
|
suggestions() {
|
||||||
if (this.searching) {
|
if (this.searching) {
|
||||||
ObjectUtils.isNotEmpty(this.suggestions) ? this.show() : this.hide();
|
ObjectUtils.isNotEmpty(this.suggestions) ? this.show() : !!this.$slots.empty ? this.show() : this.hide();
|
||||||
this.focusedOptionIndex = this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
|
this.focusedOptionIndex = this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
|
||||||
this.searching = false;
|
this.searching = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,6 +562,10 @@ export default {
|
||||||
<td>loader</td>
|
<td>loader</td>
|
||||||
<td>options: Options of the loader items for virtualscroller</td>
|
<td>options: Options of the loader items for virtualscroller</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>empty</td>
|
||||||
|
<td>-</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -605,6 +609,10 @@ export default {
|
||||||
<td>p-autocomplete-token-label</td>
|
<td>p-autocomplete-token-label</td>
|
||||||
<td>Label of a selected item in multiple mode.</td>
|
<td>Label of a selected item in multiple mode.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>p-autocomplete-empty-message</td>
|
||||||
|
<td>Container element when there is no suggestion to display.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>p-overlay-open</td>
|
<td>p-overlay-open</td>
|
||||||
<td>Container element when overlay is visible.</td>
|
<td>Container element when overlay is visible.</td>
|
||||||
|
|
Loading…
Reference in New Issue