From 3ea3e30a835cbe5f352030904c9b727a19ea0e97 Mon Sep 17 00:00:00 2001 From: Devara Eko Date: Fri, 13 Sep 2024 14:44:41 +0700 Subject: [PATCH] fix(select): fix selected values when option items updated after search --- src/components/select/Select.spec.ts | 39 +++++++++++++++++++++++++++- src/components/select/Select.vue | 36 ++++++++++++++----------- src/components/select/index.md | 20 +++++++++++++- 3 files changed, 78 insertions(+), 17 deletions(-) diff --git a/src/components/select/Select.spec.ts b/src/components/select/Select.spec.ts index 459a749aec..652cae492e 100644 --- a/src/components/select/Select.spec.ts +++ b/src/components/select/Select.spec.ts @@ -476,7 +476,7 @@ it('should have clear button if prop `clearable` was provided', async () => { await fireEvent.click(clear) - expect(model.value).toBeUndefined() + expect(model.value).toStrictEqual({ text: '', value: undefined }) }) it('should clear search keyword if click clear button when select was opened', async () => { @@ -595,3 +595,40 @@ it('should show selected items when options updated', async () => { expect(activator).toHaveTextContent('orange') }) + +it('should be keep selected when option changed after search', async () => { + const options = ref([ + 'apple', + 'grape', + 'orange', + ]) + const model = ref('apple') + const screen = render({ + components: { Select }, + template : ` +