Skip to content

Commit

Permalink
fix(modal): make sure content is ready
Browse files Browse the repository at this point in the history
fixes #14969
  • Loading branch information
manucorporat committed Aug 25, 2018
1 parent 3ffa3cd commit 2c8bc04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Animation, AnimationBuilder, ComponentProps, ComponentRef, Config, Fram
import { attachComponent, detachComponent } from '../../utils/framework-delegate';
import { BACKDROP, dismiss, eventMethod, present } from '../../utils/overlays';
import { createThemedClasses, getClassMap } from '../../utils/theme';
import { deepReady } from '../../utils/transition';

import { iosEnterAnimation } from './animations/ios.enter';
import { iosLeaveAnimation } from './animations/ios.leave';
Expand Down Expand Up @@ -134,12 +135,12 @@ export class Modal implements OverlayInterface {
const el = this.usersElement;
const name = LIFECYCLE_MAP[modalEvent.type];
if (el && name) {
const event = new CustomEvent(name, {
const ev = new CustomEvent(name, {
bubbles: false,
cancelable: false,
detail: modalEvent.detail
});
el.dispatchEvent(event);
el.dispatchEvent(ev);
}
}

Expand All @@ -160,6 +161,7 @@ export class Modal implements OverlayInterface {
modal: this.el
};
this.usersElement = await attachComponent(this.delegate, container, this.component, ['ion-page'], componentProps);
await deepReady(this.usersElement);
return present(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation);
}

Expand Down
8 changes: 7 additions & 1 deletion core/src/utils/framework-delegate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ComponentRef, FrameworkDelegate } from '../interface';

export async function attachComponent(delegate: FrameworkDelegate | undefined, container: Element, component: ComponentRef, cssClasses?: string[], componentProps?: {[key: string]: any}): Promise<HTMLElement> {
export async function attachComponent(
delegate: FrameworkDelegate | undefined,
container: Element,
component: ComponentRef,
cssClasses?: string[],
componentProps?: {[key: string]: any}
): Promise<HTMLElement> {
if (delegate) {
return delegate.attachViewToDom(container, component, componentProps, cssClasses);
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/utils/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function shallowReady(el: Element | undefined): Promise<any> {
return Promise.resolve();
}

async function deepReady(el: Element | undefined): Promise<void> {
export async function deepReady(el: Element | undefined): Promise<void> {
const element = el as HTMLStencilElement;
if (element) {
if (element.componentOnReady) {
Expand Down

0 comments on commit 2c8bc04

Please sign in to comment.