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(dialog): delay focus until animation is done #3774

Merged
merged 1 commit into from
Mar 29, 2017
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
16 changes: 9 additions & 7 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ export class MdDialogContainer extends BasePortalHost implements OnDestroy {
throw new MdDialogContentAlreadyAttachedError();
}

let attachResult = this._portalHost.attachComponentPortal(portal);
this._trapFocus();
return attachResult;
return this._portalHost.attachComponentPortal(portal);
}

/**
Expand All @@ -105,9 +103,7 @@ export class MdDialogContainer extends BasePortalHost implements OnDestroy {
throw new MdDialogContentAlreadyAttachedError();
}

let attachedResult = this._portalHost.attachTemplatePortal(portal);
this._trapFocus();
return attachedResult;
return this._portalHost.attachTemplatePortal(portal);
}

/**
Expand Down Expand Up @@ -142,6 +138,10 @@ export class MdDialogContainer extends BasePortalHost implements OnDestroy {
* @docs-private
*/
_onAnimationDone(event: AnimationEvent) {
if (event.toState === 'enter') {
this._trapFocus();
}

this._onAnimationStateChange.emit(event.toState as MdDialogContainerAnimationState);
}

Expand All @@ -162,6 +162,8 @@ export class MdDialogContainer extends BasePortalHost implements OnDestroy {
this._onAnimationStateChange.complete();
});

this._focusTrap.destroy();
if (this._focusTrap) {
this._focusTrap.destroy();
}
}
}