Skip to content

Commit f783554

Browse files
CSimoesJrarthur-polidorio
authored andcommitted
feat(components): cria atributos para compatibilidade com edição fluída
Garante compatibilidade de foco e disabled na edição fluída. fixes DTHFUI-11826
1 parent 8aa8f40 commit f783554

27 files changed

+230
-9
lines changed

projects/ui/src/lib/components/po-field/po-checkbox/po-checkbox.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
[class.po-checkbox-outline-large]="size === 'large'"
3333
[tabindex]="disabled || disabladTabindex ? -1 : 0"
3434
[attr.aria-checked]="checkboxValue"
35+
[attr.data-focused-element]="!disabled"
36+
[attr.data-inactive-component]="disabled"
3537
(blur)="onBlur()"
3638
>
3739
<span

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeDetectorRef, ElementRef } from '@angular/core';
2-
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
33

44
import { PoThemeA11yEnum } from '../../../services';
55
import { PoCheckboxComponent } from './po-checkbox.component';
@@ -34,6 +34,21 @@ describe('PoCheckboxComponent:', () => {
3434
expect(labelField).toBeTruthy();
3535
});
3636

37+
it("ngAfterViewInit: should set appendBox true if contains class 'enable-append-box'", fakeAsync(() => {
38+
component.checkboxLabel = {
39+
nativeElement: {
40+
classList: {
41+
contains: (cls: string) => cls === 'enable-append-box'
42+
}
43+
}
44+
};
45+
component.ngAfterViewInit();
46+
47+
tick(300);
48+
49+
expect(component.appendBox).toBeTrue();
50+
}));
51+
3752
describe('Methods:', () => {
3853
it('focus: should call `focus` of checkbox.', () => {
3954
component.checkboxLabel = new ElementRef({ focus() {}, label: 'test' });

projects/ui/src/lib/components/po-field/po-checkbox/po-checkbox.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ export class PoCheckboxComponent extends PoCheckboxBaseComponent implements Afte
104104
if (this.autoFocus) {
105105
this.focus();
106106
}
107+
108+
setTimeout(() => {
109+
if (this.checkboxLabel?.nativeElement?.classList?.contains('enable-append-box')) {
110+
this.appendBox = true;
111+
}
112+
}, 300);
107113
}
108114

109115
emitAdditionalHelp() {

projects/ui/src/lib/components/po-field/po-combo/po-combo.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
[class.po-input-icon-left-aa]="icon && size === 'small'"
4343
autocomplete="off"
4444
type="text"
45+
[attr.data-focused-element]="!disabled"
46+
[attr.data-inactive-component]="disabled"
4547
[attr.name]="name"
4648
[disabled]="disabled"
4749
[id]="id"

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,21 @@ describe('PoComboComponent - with service:', () => {
22172217
expect(spyFocus).not.toHaveBeenCalled();
22182218
});
22192219

2220+
it("ngAfterViewInit: should set appendBox true if contains class 'enable-append-box'", fakeAsync(() => {
2221+
component.inputEl = {
2222+
nativeElement: {
2223+
classList: {
2224+
contains: (cls: string) => cls === 'enable-append-box'
2225+
}
2226+
}
2227+
};
2228+
component.ngAfterViewInit();
2229+
2230+
tick(300);
2231+
2232+
expect(component.appendBox).toBeTrue();
2233+
}));
2234+
22202235
it('ngOnDestroy: should not unsubscribe if getSubscription is falsy.', () => {
22212236
component['getSubscription'] = fakeSubscription;
22222237

projects/ui/src/lib/components/po-field/po-combo/po-combo.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ export class PoComboComponent extends PoComboBaseComponent implements AfterViewI
171171
}
172172

173173
this.setContainerWidth();
174+
175+
// Necessário para edição fluída
176+
setTimeout(() => {
177+
if (this.inputEl?.nativeElement?.classList?.contains('enable-append-box')) {
178+
this.appendBox = true;
179+
}
180+
}, 300);
174181
}
175182

176183
ngOnChanges(changes: SimpleChanges) {

projects/ui/src/lib/components/po-field/po-datepicker/po-datepicker.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
[class.po-input-icon-right-aa]="clean && inp.value && size === 'small'"
2121
[class.po-input-aa]="size === 'small'"
2222
type="text"
23+
[attr.data-focused-element]="!disabled"
24+
[attr.data-inactive-component]="disabled || readonly"
2325
[attr.name]="name"
2426
[autocomplete]="autocomplete"
2527
[disabled]="disabled"
@@ -69,7 +71,7 @@
6971
}
7072

7173
<ng-template #sharedCalendarContent>
72-
<div #dialogPicker [class.po-datepicker-popup-calendar]="!verifyMobile()" tabindex="-1">
74+
<div #dialogPicker [class.po-datepicker-popup-calendar]="!verifyMobile()" tabindex="-1" [hidden]="!visible">
7375
@if (verifyMobile()) {
7476
<div class="po-datepicker-calendar-overlay"></div>
7577
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,26 @@ describe('PoDatepickerComponent:', () => {
17201720
expect(component.focus).not.toHaveBeenCalled();
17211721
});
17221722
});
1723+
1724+
it("ngAfterViewInit: should set appendBox true if contains class 'enable-append-box'", fakeAsync(() => {
1725+
component.inputEl = {
1726+
nativeElement: {
1727+
classList: {
1728+
contains: (cls: string) => cls === 'enable-append-box'
1729+
}
1730+
}
1731+
};
1732+
component.iconDatepicker = {
1733+
buttonElement: {
1734+
nativeElement: document.createElement('button')
1735+
}
1736+
} as PoButtonComponent;
1737+
component.ngAfterViewInit();
1738+
1739+
tick(300);
1740+
1741+
expect(component.appendBox).toBeTrue();
1742+
}));
17231743
});
17241744
});
17251745

projects/ui/src/lib/components/po-field/po-datepicker/po-datepicker.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ export class PoDatepickerComponent extends PoDatepickerBaseComponent implements
188188
this.focus();
189189
}
190190
this.renderer.setAttribute(this.iconDatepicker.buttonElement.nativeElement, 'aria-label', this.literals.open);
191+
192+
// Necessário para edição fluída
193+
setTimeout(() => {
194+
if (this.inputEl?.nativeElement?.classList?.contains('enable-append-box')) {
195+
this.appendBox = true;
196+
}
197+
}, 300);
191198
}
192199

193200
ngOnDestroy() {

projects/ui/src/lib/components/po-field/po-decimal/po-decimal.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<input
2222
#inp
2323
class="po-input"
24+
[attr.data-focused-element]="!disabled"
25+
[attr.data-inactive-component]="disabled || readonly"
2426
[attr.max]="max"
2527
[attr.min]="min"
2628
[attr.name]="name"

0 commit comments

Comments
 (0)