From f8d93a3cd7913c68fe91237bddf6dfd7ff810cb2 Mon Sep 17 00:00:00 2001 From: Luiz Gustavo da Silva Vasconcellos Date: Mon, 18 Aug 2025 08:42:44 -0300 Subject: [PATCH 1/2] =?UTF-8?q?feat(modal):=20adiciona=20suporte=20a=20?= =?UTF-8?q?=C3=ADcone=20nas=20a=C3=A7=C3=B5es=20do=20modal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O componente po-modal não permitia exibir ícones nos botões de ação. Adiciona a propriedade `icon` na interface `PoModalAction` e vincula `[p-icon]` nos botões primário e secundário do template do modal. Fixes DTHFUI-11656 --- .../src/lib/components/po-modal/po-modal-action.interface.ts | 3 +++ .../ui/src/lib/components/po-modal/po-modal.component.html | 2 ++ 2 files changed, 5 insertions(+) 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 @@ Date: Mon, 18 Aug 2025 08:46:31 -0300 Subject: [PATCH 2/2] fix(dropdown): corrige fluxo de encerramento e restaura foco MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Evita chamadas indevidas de close no popup e garante que o foco retorne ao elemento do dropdown após o fechamento. Torna o método `hideDropdown` acessível a subclasses e adiciona listener de fechamento `(p-close)="hideDropdown()"` no template para manter o estado consistente. Fixes DTHFUI-11656 --- .../components/po-dropdown/po-dropdown.component.html | 1 + .../components/po-dropdown/po-dropdown.component.spec.ts | 9 ++++++++- .../lib/components/po-dropdown/po-dropdown.component.ts | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-) 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(); }