Skip to content

Commit

Permalink
fix(toast): close toasts when two or more are open (#6814)
Browse files Browse the repository at this point in the history
* fix(toast): close toast when two or more are open

* fix(toast): abc order imports

* fix(toast): move focus code into ionic event
  • Loading branch information
jgw96 authored and danbucholtz committed Jun 9, 2016
1 parent 922a8a3 commit 8ff2476
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/components/toast/toast.ts
@@ -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 {Animation} from '../../animations/animation';
Expand Down Expand Up @@ -158,7 +158,7 @@ const TOAST_POSITION_BOTTOM: string = 'bottom';
'[attr.aria-describedby]': 'descId',
},
})
class ToastCmp {
class ToastCmp implements AfterViewInit {
private d: any;
private descId: string;
private hdrId: string;
Expand Down Expand Up @@ -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() {
const { activeElement }: any = document;
if (activeElement) {
Expand All @@ -199,14 +209,6 @@ class ToastCmp {
if (focusableEle) {
focusableEle.focus();
}

// if there's a `duration` set, automatically dismiss.
if (this.d.duration) {
this.dismissTimeout =
setTimeout(() => {
this.dismiss('backdrop');
}, this.d.duration);
}
}

cbClick() {
Expand Down

0 comments on commit 8ff2476

Please sign in to comment.