Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fix(AutoComplete): broken AutoComplete in certain case
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi authored and kelsos committed Jun 18, 2024
1 parent dac6de0 commit 01fee4e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 17 additions & 1 deletion src/components/forms/auto-complete/RuiAutoComplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,23 @@ describe('autocomplete', () => {
expect(highlightedItemButton.classList).toContain('highlighted');

await wrapper.find('[data-id=activator]').trigger('keydown.enter');
expect(wrapper.emitted().input!.at(-1)![0]).toBe(newSelectedIndex.toString());
const newSelectedIndexToString = newSelectedIndex.toString();
expect(wrapper.emitted().input!.at(-1)![0]).toBe(newSelectedIndexToString);

// Delete option should also remove selected value with that option
const newOptions = options.filter(item => item.id !== newSelectedIndexToString);

await wrapper.setProps({
options: newOptions,
});
await nextTick();

expect(wrapper.emitted().input!.at(-1)![0]).toEqual(null);

// doesn't break when use chips
await wrapper.setProps({
chips: true,
});
});

it('multiple value', async () => {
Expand Down
9 changes: 4 additions & 5 deletions src/components/forms/auto-complete/RuiAutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ const value = computed<(T extends string ? T : Record<K, T>)[]>({
return filtered.push(textValueToProperValue(val));
});
if (multipleVal) {
return filtered;
}
else if (filtered.length === 0 && get(shouldApplyValueAsSearch)) {
updateInternalSearch();
if (multipleVal || filtered.length === 0) {
if (get(shouldApplyValueAsSearch))
updateInternalSearch();
return filtered;
}
else {
Expand Down

0 comments on commit 01fee4e

Please sign in to comment.