mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
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:

committed by
Dan Bucholtz

parent
922a8a3ba9
commit
8ff2476cc3
@ -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';
|
||||
@ -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;
|
||||
@ -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) {
|
||||
@ -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() {
|
||||
|
Reference in New Issue
Block a user