diff --git a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.html b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.html index 3e2fc32e0..627d6d047 100644 --- a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.html +++ b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.html @@ -26,5 +26,6 @@ [p-custom-positions]="['bottom-left', 'top-left']" [p-size]="size" [p-target]="dropdownRef" + (p-close)="hideDropdown()" > diff --git a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.spec.ts b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.spec.ts index 4a3213ee0..dc28eba53 100644 --- a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.spec.ts +++ b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.spec.ts @@ -129,7 +129,13 @@ describe('PoDropdownComponent: ', () => { icon: undefined, removeListeners: jasmine.createSpy('removeListeners'), popupRef: { - close: jasmine.createSpy('close') + close: jasmine.createSpy('close'), + showPopup: true + }, + dropdownRef: { + nativeElement: { + focus: jasmine.createSpy('focus') + } }, open: undefined, changeDetector: { @@ -142,6 +148,7 @@ describe('PoDropdownComponent: ', () => { expect(fakeThis.icon).toBe('ICON_ARROW_DOWN'); expect(fakeThis.removeListeners).toHaveBeenCalled(); expect(fakeThis.popupRef.close).toHaveBeenCalled(); + expect(fakeThis.dropdownRef.nativeElement.focus).toHaveBeenCalled(); expect(fakeThis.open).toBe(false); expect(fakeThis.changeDetector.detectChanges).toHaveBeenCalled(); }); diff --git a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.ts b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.ts index 9178d818b..650b528ce 100644 --- a/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.ts +++ b/projects/ui/src/lib/components/po-dropdown/po-dropdown.component.ts @@ -62,10 +62,13 @@ export class PoDropdownComponent extends PoDropdownBaseComponent { return this.dropdownRef && this.dropdownRef.nativeElement.contains(event.target); } - private hideDropdown() { + protected hideDropdown() { this.icon = 'ICON_ARROW_DOWN'; this.removeListeners(); - this.popupRef.close(); + if (this.popupRef.showPopup) { + this.popupRef.close(); + } + this.dropdownRef.nativeElement.focus(); this.open = false; this.changeDetector.detectChanges(); } diff --git a/projects/ui/src/lib/components/po-modal/po-modal-action.interface.ts b/projects/ui/src/lib/components/po-modal/po-modal-action.interface.ts index d312f7852..acf34f869 100644 --- a/projects/ui/src/lib/components/po-modal/po-modal-action.interface.ts +++ b/projects/ui/src/lib/components/po-modal/po-modal-action.interface.ts @@ -19,6 +19,9 @@ export interface PoModalAction { /** Desabilita o botão impossibilitando que sua ação seja executada. */ disabled?: boolean; + /** Define o ícone do botão. */ + icon?: string; + /** Rótulo do botão. */ label: string; diff --git a/projects/ui/src/lib/components/po-modal/po-modal.component.html b/projects/ui/src/lib/components/po-modal/po-modal.component.html index 471f0e685..2bb8bfecb 100644 --- a/projects/ui/src/lib/components/po-modal/po-modal.component.html +++ b/projects/ui/src/lib/components/po-modal/po-modal.component.html @@ -36,6 +36,7 @@