fix(toast): close toasts when two or more are open (#6814)

* fix(toast): close toast when two or more are open

* fix(toast): abc order imports

* fix(toast): move focus code into ionic event
This commit is contained in:
Justin Willis
2016-06-09 13:02:53 -05:00
committed by Dan Bucholtz
parent 922a8a3ba9
commit 8ff2476cc3

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Renderer, Output, EventEmitter} from '@angular/core'; import {AfterViewInit, Component, ElementRef, EventEmitter, Output, Renderer} from '@angular/core';
import {ActionSheet, ActionSheetOptions} from '../action-sheet/action-sheet'; import {ActionSheet, ActionSheetOptions} from '../action-sheet/action-sheet';
import {Animation} from '../../animations/animation'; import {Animation} from '../../animations/animation';
@ -158,7 +158,7 @@ const TOAST_POSITION_BOTTOM: string = 'bottom';
'[attr.aria-describedby]': 'descId', '[attr.aria-describedby]': 'descId',
}, },
}) })
class ToastCmp { class ToastCmp implements AfterViewInit {
private d: any; private d: any;
private descId: string; private descId: string;
private hdrId: string; private hdrId: string;
@ -188,6 +188,16 @@ class ToastCmp {
} }
} }
ngAfterViewInit() {
// if there's a `duration` set, automatically dismiss.
if (this.d.duration) {
this.dismissTimeout =
setTimeout(() => {
this.dismiss('backdrop');
}, this.d.duration);
}
}
ionViewDidEnter() { ionViewDidEnter() {
const { activeElement }: any = document; const { activeElement }: any = document;
if (activeElement) { if (activeElement) {
@ -199,14 +209,6 @@ class ToastCmp {
if (focusableEle) { if (focusableEle) {
focusableEle.focus(); focusableEle.focus();
} }
// if there's a `duration` set, automatically dismiss.
if (this.d.duration) {
this.dismissTimeout =
setTimeout(() => {
this.dismiss('backdrop');
}, this.d.duration);
}
} }
cbClick() { cbClick() {