From 6f06f48bbbf276034a909ce2f86d023f452196fb Mon Sep 17 00:00:00 2001
From: matthiashader <144090716+matthiashader@users.noreply.github.com>
Date: Thu, 12 Oct 2023 11:49:48 +0200
Subject: [PATCH] bug(core/select): fixed behaviour and added test for new
behaviour
---
.../core/src/components/select/select.tsx | 8 +++++--
.../src/components/select/test/select.ct.ts | 23 ++++++++++++++++++-
packages/core/src/index.html | 4 ++++
3 files changed, 32 insertions(+), 3 deletions(-)
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(`
+