Skip to content

Commit

Permalink
fix(core/select): update input value on slot change (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiashader authored Nov 5, 2024
1 parent 9951af3 commit 19b6842
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-pugs-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

fix(core/select): update input value on slot change
7 changes: 7 additions & 0 deletions packages/core/src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@
}
}

ix-icon-button {
height: 1.875rem;
width: 1.875rem;
min-height: 1.875rem;
min-width: 1.875rem;
}

input {
@include ellipsis;
@include text-default;
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,11 @@ export class Select {
>
{this.i18nSelectListHeader}
</div>
<slot></slot>
<slot
onSlotchange={() => {
this.updateSelection();
}}
></slot>
<div
ref={(ref) => (this.customItemsContainerRef = ref)}
class="d-contents"
Expand Down
26 changes: 23 additions & 3 deletions packages/core/src/components/select/test/select.ct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,8 @@ test.describe('Events', () => {
const select = await page.locator('ix-select');
const valueChanged = select.evaluate((elm) => {
return new Promise<number>((resolve) => {
elm.addEventListener('valueChange', (e: CustomEvent) =>
resolve(e.detail)
elm.addEventListener('valueChange', (e: Event) =>
resolve((e as CustomEvent).detail)
);
});
});
Expand All @@ -753,7 +753,9 @@ test.describe('Events', () => {
const select = await page.locator('ix-select');
const itemAdded = select.evaluate((elm) => {
return new Promise<number>((resolve) => {
elm.addEventListener('addItem', (e: CustomEvent) => resolve(e.detail));
elm.addEventListener('addItem', (e: Event) =>
resolve((e as CustomEvent).detail)
);
});
});
const input = await page.locator('input');
Expand Down Expand Up @@ -795,3 +797,21 @@ test.describe('Events', () => {
});
});
});

test('async set content and check input value', async ({ mount, page }) => {
await mount(`<ix-select value="1"></ix-select>`);

await page.evaluate(async () => {
const select = document.querySelector('ix-select');
if (select) {
await new Promise((resolve) => setTimeout(resolve, 1000));
select.innerHTML = `
<ix-select-item value="1" label="Item 1">Test</ix-select-item>
<ix-select-item value="2" label="Item 2">Test</ix-select-item>
`;
}
});

const input = page.locator('input');
await expect(input).toHaveValue('Item 1');
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 19b6842

Please sign in to comment.