Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/select): update input value on slot change #1548

Merged
merged 15 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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;
6 changes: 5 additions & 1 deletion packages/core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
@@ -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"
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
@@ -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)
);
});
});
@@ -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');
@@ -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.

Unchanged files with check annotations Beta

});
}
async function fallbackRemoveViewFromRootDom(view: any) {

Check warning on line 38 in packages/react/src/delegate.ts

GitHub Actions / build

Unexpected any. Specify a different type
const parent = view.parentElement;
const id = parent.id;
if (id in mountedRootNodes) {
}
export class ReactFrameworkDelegate implements FrameworkDelegate {
attachViewToPortal?: (id: string, view: any) => Promise<Element>;

Check warning on line 49 in packages/react/src/delegate.ts

GitHub Actions / build

Unexpected any. Specify a different type
removeViewFromPortal?: (id: string) => void;
resolvePortalInitPromise: (() => void) | undefined;
);
}
async attachView(view: any): Promise<any> {

Check warning on line 62 in packages/react/src/delegate.ts

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 62 in packages/react/src/delegate.ts

GitHub Actions / build

Unexpected any. Specify a different type
const id = createViewInstance();
if (!this.isUsingReactPortal) {
console.error('Portal could not be initialized');
}
async removeView(view: any): Promise<void> {

Check warning on line 78 in packages/react/src/delegate.ts

GitHub Actions / build

Unexpected any. Specify a different type
if (!this.removeViewFromPortal) {
return fallbackRemoveViewFromRootDom(view);
}
import { IxModal } from '../components';
export interface ModalRef {
close: <T = any>(result: T) => void;

Check warning on line 13 in packages/react/src/modal/modal.tsx

GitHub Actions / build

Unexpected any. Specify a different type
dismiss: <T = any>(result?: T) => void;

Check warning on line 14 in packages/react/src/modal/modal.tsx

GitHub Actions / build

Unexpected any. Specify a different type
modalElement: HTMLIxModalElement | null;
}
Record<string, (value: Element | PromiseLike<Element>) => void>
>({});
const viewRefs = useRef<Record<string, any>>({});

Check warning on line 23 in packages/react/src/modal/portal.tsx

GitHub Actions / build

Unexpected any. Specify a different type
const [views, setViews] = useState<Record<string, any>>({});

Check warning on line 24 in packages/react/src/modal/portal.tsx

GitHub Actions / build

Unexpected any. Specify a different type
useEffect(() => {
const addOverlay = (id: string, view: any) => {

Check warning on line 27 in packages/react/src/modal/portal.tsx

GitHub Actions / build

Unexpected any. Specify a different type
const _views = { ...viewRefs.current };
_views[id] = view;
setViews(_views);