diff --git a/components/lib/autocomplete/AutoComplete.spec.js b/components/lib/autocomplete/AutoComplete.spec.js index 7ca9297b3..ab8e2e1c7 100644 --- a/components/lib/autocomplete/AutoComplete.spec.js +++ b/components/lib/autocomplete/AutoComplete.spec.js @@ -55,6 +55,21 @@ describe('AutoComplete.vue', () => { expect(wrapper.findAll('.p-autocomplete-item').length).toBe(1); }); + it('should show overlay and empty-message if there are no suggestions', async () => { + const event = { target: { value: 'b' } }; + + wrapper.vm.search(event, event.target.value, 'input'); + await wrapper.vm.$nextTick(); + + await wrapper.setProps({ + suggestions: [] + }); + + expect(wrapper.find('.p-autocomplete-items').exists()).toBe(true); + expect(wrapper.findAll('.p-autocomplete-item').length).toBe(0); + expect(wrapper.find('.p-autocomplete-empty-message').exists()).toBe(true); + }); + it('dropdown', () => { it('should have correct custom icon', async () => { wrapper.setProps({ diff --git a/components/lib/autocomplete/AutoComplete.vue b/components/lib/autocomplete/AutoComplete.vue index 7d7822e94..96530978e 100755 --- a/components/lib/autocomplete/AutoComplete.vue +++ b/components/lib/autocomplete/AutoComplete.vue @@ -215,7 +215,7 @@ export default { }, suggestions() { if (this.searching) { - ObjectUtils.isNotEmpty(this.suggestions) ? this.show() : !!this.$slots.empty ? this.show() : this.hide(); + this.show(); this.focusedOptionIndex = this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1; this.searching = false; }