Skip to content

Commit

Permalink
fix(angular): prevent duplicate event emissions (#24200)
Browse files Browse the repository at this point in the history
* fix(angular-output-targets): prevent duplicate event emissions

* feat(angular-output-target): update package to ^0.2.1
  • Loading branch information
sean-perkins authored Nov 11, 2021
1 parent 0bb8e88 commit fc1eae9
Show file tree
Hide file tree
Showing 5 changed files with 600 additions and 283 deletions.
45 changes: 36 additions & 9 deletions angular/src/directives/overlays/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,41 @@ import {
} from '@angular/core';
import { ProxyCmp, proxyOutputs } from '../angular-component-lib/utils';
import { Components } from '@ionic/core';
export declare interface IonModal extends Components.IonModal {}

export declare interface IonModal extends Components.IonModal {
/**
* Emitted after the modal has presented.
**/
ionModalDidPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the modal has presented.
*/
ionModalWillPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the modal has dismissed.
*/
ionModalWillDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the modal has dismissed.
*/
ionModalDidDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the modal has presented. Shorthand for ionModalWillDismiss.
*/
didPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the modal has presented. Shorthand for ionModalWillPresent.
*/
willPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the modal has dismissed. Shorthand for ionModalWillDismiss.
*/
willDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the modal has dismissed. Shorthand for ionModalDidDismiss.
*/
didDismiss: EventEmitter<CustomEvent>;
}
@ProxyCmp({
inputs: [
'animated',
Expand Down Expand Up @@ -64,17 +98,10 @@ export declare interface IonModal extends Components.IonModal {}
export class IonModal {
@ContentChild(TemplateRef, { static: false }) template: TemplateRef<any>;

ionModalDidPresent!: EventEmitter<CustomEvent>;
ionModalWillPresent!: EventEmitter<CustomEvent>;
ionModalWillDismiss!: EventEmitter<CustomEvent>;
ionModalDidDismiss!: EventEmitter<CustomEvent>;
didPresent!: EventEmitter<CustomEvent>;
willPresent!: EventEmitter<CustomEvent>;
willDismiss!: EventEmitter<CustomEvent>;
didDismiss!: EventEmitter<CustomEvent>;
isCmpOpen: boolean = false;

protected el: HTMLElement;

constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
Expand Down
45 changes: 35 additions & 10 deletions angular/src/directives/overlays/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,40 @@ import {
} from '@angular/core';
import { ProxyCmp, proxyOutputs } from '../angular-component-lib/utils';
import { Components } from '@ionic/core';
export declare interface IonPopover extends Components.IonPopover {}
export declare interface IonPopover extends Components.IonPopover {
/**
* Emitted after the popover has presented.
*/
ionPopoverDidPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the popover has presented.
*/
ionPopoverWillPresent: EventEmitter<CustomEvent>;
/**
* Emitted after the popover has dismissed.
*/
ionPopoverWillDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the popover has dismissed.
*/
ionPopoverDidDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the popover has presented. Shorthand for ionPopoverWillDismiss.
*/
didPresent: EventEmitter<CustomEvent>;
/**
* Emitted before the popover has presented. Shorthand for ionPopoverWillPresent.
*/
willPresent: EventEmitter<CustomEvent>;
/**
* Emitted after the popover has presented. Shorthand for ionPopoverWillDismiss.
*/
willDismiss: EventEmitter<CustomEvent>;
/**
* Emitted after the popover has dismissed. Shorthand for ionPopoverDidDismiss.
*/
didDismiss: EventEmitter<CustomEvent>;
}
@ProxyCmp({
inputs: [
'alignment',
Expand Down Expand Up @@ -64,17 +97,10 @@ export declare interface IonPopover extends Components.IonPopover {}
export class IonPopover {
@ContentChild(TemplateRef, { static: false }) template: TemplateRef<any>;

ionPopoverDidPresent!: EventEmitter<CustomEvent>;
ionPopoverWillPresent!: EventEmitter<CustomEvent>;
ionPopoverWillDismiss!: EventEmitter<CustomEvent>;
ionPopoverDidDismiss!: EventEmitter<CustomEvent>;
didPresent!: EventEmitter<CustomEvent>;
willPresent!: EventEmitter<CustomEvent>;
willDismiss!: EventEmitter<CustomEvent>;
didDismiss!: EventEmitter<CustomEvent>;
isCmpOpen: boolean = false;

protected el: HTMLElement;

constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
Expand All @@ -87,7 +113,6 @@ export class IonPopover {
this.isCmpOpen = false;
c.detectChanges();
});

proxyOutputs(this, this.el, [
'ionPopoverDidPresent',
'ionPopoverWillPresent',
Expand Down
Loading

0 comments on commit fc1eae9

Please sign in to comment.