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(overlays): presenting an overlay does not create nested elements #26154

Merged
merged 10 commits into from
Nov 2, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test.describe('datetime-button: switching to correct view', () => {
expect(datetime).toHaveJSProperty('presentation', 'date-time');

await page.locator('#date-button').click();
await page.waitForChanges();

expect(datetime).toHaveJSProperty('presentation', 'date');
});
Expand All @@ -25,6 +26,7 @@ test.describe('datetime-button: switching to correct view', () => {
expect(datetime).toHaveJSProperty('presentation', 'date-time');

await page.locator('#time-button').click();
await page.waitForChanges();

expect(datetime).toHaveJSProperty('presentation', 'time');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,24 @@ test.describe('datetime-button: modal', () => {
await ionModalDidPresent.next();
expect(datetime).toBeVisible();
});
test('datetime should be the first child of the modal', async ({ page }, testInfo) => {
sean-perkins marked this conversation as resolved.
Show resolved Hide resolved
testInfo.annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/26117',
});

await page.locator('#date-button').click();
await ionModalDidPresent.next();
expect(datetime).toBeVisible();

expect(await modal.evaluate((el: HTMLIonModalElement) => el.firstElementChild!.tagName)).toBe('ION-DATETIME');
await modal.evaluate((el: HTMLIonModalElement) => el.dismiss());
await ionModalDidDismiss.next();

await page.locator('#date-button').click();
await ionModalDidPresent.next();
expect(datetime).toBeVisible();

expect(await modal.evaluate((el: HTMLIonModalElement) => el.firstElementChild!.tagName)).toBe('ION-DATETIME');
});
});
4 changes: 3 additions & 1 deletion core/src/utils/framework-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const CoreDelegate = () => {
userComponentProps: any = {},
cssClasses: string[] = []
) => {
const hasUserDefinedComponent = userComponent !== undefined;

BaseComponent = parentElement;
/**
* If passing in a component via the `component` props
Expand Down Expand Up @@ -86,7 +88,7 @@ export const CoreDelegate = () => {
BaseComponent.appendChild(el);

await new Promise((resolve) => componentOnReady(el, resolve));
} else if (BaseComponent.children.length > 0) {
} else if (hasUserDefinedComponent && BaseComponent.children.length > 0) {
sean-perkins marked this conversation as resolved.
Show resolved Hide resolved
// If there is no component, then we need to create a new parent
// element to apply the css classes to.
const el = BaseComponent.ownerDocument?.createElement('div');
Expand Down