Skip to content

Commit 6134b83

Browse files
alinelariguetsamir-ayoub
authored andcommitted
feat(popover): inclui evento ao fechar
Inclui evento ao fechar o popover. Fixes DTHFUI-3699
1 parent 03dd53d commit 6134b83

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

projects/ui/src/lib/components/po-popover/po-popover-base.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ElementRef, Input, Directive } from '@angular/core';
1+
import { ElementRef, EventEmitter, Input, Directive, Output } from '@angular/core';
22

33
import { convertToBoolean } from '../../utils/util';
44
import { PO_CONTROL_POSITIONS } from './../../services/po-control-position/po-control-position.constants';
@@ -136,6 +136,9 @@ export class PoPopoverBaseComponent {
136136
return this._trigger;
137137
}
138138

139+
/** Evento disparado ao fechar o popover. */
140+
@Output('p-close') closePopover = new EventEmitter<any>();
141+
139142
protected clickoutListener: () => void;
140143
protected mouseEnterListener: () => void;
141144
protected mouseLeaveListener: () => void;

projects/ui/src/lib/components/po-popover/po-popover.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ describe('PoPopoverComponent:', () => {
203203
expect(fakeThis.setElementsControlPosition).toHaveBeenCalled();
204204
}));
205205

206-
it('should close popover', () => {
206+
it('should close popover and call `closePopover.emit`', () => {
207+
spyOn(component.closePopover, 'emit');
207208
component.isHidden = false;
208209

209210
component.close();
210211

211212
expect(component.isHidden).toBeTruthy();
213+
expect(component.closePopover.emit).toHaveBeenCalled();
212214
});
213215

214216
it('should set opacity', () => {

projects/ui/src/lib/components/po-popover/po-popover.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { AfterViewInit, Component, ElementRef, OnDestroy, Renderer2, ViewChild } from '@angular/core';
1+
import {
2+
AfterViewInit,
3+
Component,
4+
ElementRef,
5+
EventEmitter,
6+
OnDestroy,
7+
Output,
8+
Renderer2,
9+
ViewChild
10+
} from '@angular/core';
211

312
import { PoControlPositionService } from './../../services/po-control-position/po-control-position.service';
413
import { PoPopoverBaseComponent } from './po-popover-base.component';
@@ -55,6 +64,7 @@ export class PoPopoverComponent extends PoPopoverBaseComponent implements AfterV
5564

5665
close(): void {
5766
this.isHidden = true;
67+
this.closePopover.emit();
5868
}
5969

6070
debounceResize() {

0 commit comments

Comments
 (0)