diff --git a/packages/core/src/components/select/select.tsx b/packages/core/src/components/select/select.tsx index 6ed1286ef57..ab6fb81da71 100644 --- a/packages/core/src/components/select/select.tsx +++ b/packages/core/src/components/select/select.tsx @@ -307,8 +307,12 @@ export class Select { this.isDropdownEmpty = this.isEveryDropdownItemHidden; } else { this.navigationItem = undefined; - this.inputFilterText = undefined; - this.inputRef.value = this.selectedLabels[0]; + + if (this.selectedLabels[0] && !this.isMultipleMode) { + this.inputRef.value = this.selectedLabels[0]; + } else { + this.clearInput(); + } } } diff --git a/packages/core/src/components/select/test/select.ct.ts b/packages/core/src/components/select/test/select.ct.ts index 921de0f86d0..87eeda0302c 100644 --- a/packages/core/src/components/select/test/select.ct.ts +++ b/packages/core/src/components/select/test/select.ct.ts @@ -61,7 +61,7 @@ test('editable mode', async ({ mount, page }) => { .getByRole('listitem') .filter({ hasText: 'Not existing' }); - await expect(addedItem).toBeVisible(); + await expect(addedItem.first()).toBeVisible(); }); test('single selection', async ({ mount, page }) => { @@ -150,3 +150,24 @@ test('filter', async ({ mount, page }) => { await expect(item4).not.toBeVisible(); await expect(item_abc).toBeVisible(); }); + +test('display selected option', async ({ mount, page }) => { + await mount(` + + Test + Test + + `); + const element = page.locator('ix-select'); + await element.evaluate( + (select: HTMLIxSelectElement) => (select.value = '22') + ); + + await page.locator('[data-select-dropdown]').click(); + await page.getByTestId('input').fill('Not existing'); + + await page.click('body'); + + const inputText = await page.inputValue('input'); + expect(inputText).toEqual('Item 2'); +}); diff --git a/packages/core/src/index.html b/packages/core/src/index.html index a39e89d706f..f59009a5724 100644 --- a/packages/core/src/index.html +++ b/packages/core/src/index.html @@ -30,5 +30,9 @@ + + Test + Test +