AutoComplete: show overlay if there are no suggestions (#3866)

* fix(autocomplete): show overlay if there are no suggestions

* test(autocomplete): show overlay if there are no suggestions

* chore: formatting
pull/4142/head
Paul Thiel 2023-09-05 03:19:51 +02:00 committed by GitHub
parent 1695365111
commit 07e9773db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -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({

View File

@ -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;
}