Skip to content

Commit 5e47c82

Browse files
jnrpalmaalinelariguet
authored andcommitted
feat(tag): ajusta area de click minima
Implementa área de click mínima de `44px` somente para a tag com `p-click` habilitada. Fixes DTHFUI-7938
1 parent 807c383 commit 5e47c82

File tree

3 files changed

+56
-47
lines changed

3 files changed

+56
-47
lines changed

projects/ui/src/lib/components/po-tag/po-tag.component.html

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,68 @@
55

66
<div class="po-tag-sub-container">
77
<div
8-
#poTag
9-
class="po-tag"
10-
[attr.role]="isClickable && !disabled ? 'button' : ''"
8+
#poTagWrapper
9+
class="po-tag-wrapper"
1110
[class.po-clickable]="isClickable && !disabled && !removable"
12-
[class.po-tag-inverse]="inverse && !type && !customTextColor && !removable"
13-
[class.po-tag-removable]="removable"
14-
[class.po-tag-disabled]="disabled && removable"
15-
[ngClass]="tagColor"
16-
[ngStyle]="styleTag()"
17-
[tabindex]="isClickable && !removable ? 0 : -1"
18-
(click)="onClick()"
11+
[attr.role]="isClickable && !disabled && !removable ? 'button' : ''"
1912
(keydown.enter)="onKeyPressed($event)"
2013
(keydown.space)="$event.preventDefault()"
2114
(keyup.space)="onKeyPressed($event)"
15+
(click)="onClick()"
16+
[tabindex]="isClickable && !removable ? 0 : -1"
2217
>
23-
<po-icon
24-
*ngIf="icon && !removable"
25-
class="po-tag-icon"
26-
[p-icon]="!type ? icon : iconFromType"
27-
[ngStyle]="
28-
!tagColor && inverse && !customTextColor
29-
? { 'color': customColor }
30-
: !type && customTextColor
31-
? { 'color': customTextColor }
32-
: ''
33-
"
18+
<div
19+
#poTag
20+
class="po-tag"
21+
[class.po-clickable]="isClickable && !disabled && !removable"
22+
[class.po-tag-inverse]="inverse && !type && !customTextColor && !removable"
23+
[class.po-tag-removable]="removable"
24+
[class.po-tag-disabled]="disabled && removable"
25+
[ngClass]="tagColor"
26+
[ngStyle]="styleTag()"
3427
>
35-
</po-icon>
36-
37-
<div #tagContainer class="po-tag-value" [p-tooltip]="getWidthTag() ? value : ''" p-tooltip-position="top">
38-
<span
28+
<po-icon
29+
*ngIf="icon && !removable"
30+
class="po-tag-icon"
31+
[p-icon]="!type ? icon : iconFromType"
3932
[ngStyle]="
4033
!tagColor && inverse && !customTextColor
4134
? { 'color': customColor }
42-
: !type && customTextColor && !removable
35+
: !type && customTextColor
4336
? { 'color': customTextColor }
4437
: ''
4538
"
46-
>{{ value }}</span
4739
>
48-
</div>
40+
</po-icon>
4941

50-
<span
51-
#tagClose
52-
*ngIf="removable"
53-
p-tooltip-position="top"
54-
[p-tooltip]="literals.remove"
55-
[attr.aria-label]="setAriaLabel()"
56-
class="po-tag-remove po-icon po-icon-close"
57-
[class.po-clickable]="!disabled"
58-
[tabindex]="!disabled ? 0 : -1"
59-
[attr.role]="!disabled ? 'button' : ''"
60-
(click)="onClose()"
61-
(keydown.enter)="onClose('enter')"
62-
>
63-
</span>
42+
<div #tagContainer class="po-tag-value" [p-tooltip]="getWidthTag() ? value : ''" p-tooltip-position="top">
43+
<span
44+
[ngStyle]="
45+
!tagColor && inverse && !customTextColor
46+
? { 'color': customColor }
47+
: !type && customTextColor && !removable
48+
? { 'color': customTextColor }
49+
: ''
50+
"
51+
>{{ value }}</span
52+
>
53+
</div>
54+
55+
<span
56+
#tagClose
57+
*ngIf="removable"
58+
p-tooltip-position="top"
59+
[p-tooltip]="literals.remove"
60+
[attr.aria-label]="setAriaLabel()"
61+
class="po-tag-remove po-icon po-icon-close"
62+
[class.po-clickable]="!disabled"
63+
[tabindex]="!disabled ? 0 : -1"
64+
[attr.role]="!disabled ? 'button' : ''"
65+
(click)="onClose()"
66+
(keydown.enter)="onClose('enter')"
67+
>
68+
</span>
69+
</div>
6470
</div>
6571
</div>
6672
</div>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('PoTagComponent:', () => {
149149
it('onKeyPressed: should call `onClick` if the event `keydown` is used with `enter` key.', () => {
150150
fixture.detectChanges();
151151

152-
const tagElement = fixture.debugElement.query(By.css('.po-tag'));
152+
const tagElement = fixture.debugElement.query(By.css('.po-tag-wrapper'));
153153
const spyOnClick = spyOn(component, 'onClick');
154154

155155
tagElement.triggerEventHandler('keydown.enter', fakeEvent);
@@ -171,7 +171,7 @@ describe('PoTagComponent:', () => {
171171
it('onKeyPressed: should call `onClick` if the event `keyup` is used with `space` key.', () => {
172172
fixture.detectChanges();
173173

174-
const tagElement = fixture.debugElement.query(By.css('.po-tag'));
174+
const tagElement = fixture.debugElement.query(By.css('.po-tag-wrapper'));
175175
const spyOnClick = spyOn(component, 'onClick');
176176

177177
tagElement.triggerEventHandler('keyup.space', fakeEvent);
@@ -191,12 +191,13 @@ describe('PoTagComponent:', () => {
191191
});
192192

193193
it('onClose: Should have been called onClose', () => {
194-
spyOn(component.click, <any>'emit');
195194
spyOn(component, <any>'onRemove');
195+
spyOn(component.remove, 'emit');
196196

197197
component.onClose();
198198

199-
expect(component.click.emit).toHaveBeenCalledWith('click');
199+
expect(component['onRemove']).toHaveBeenCalled();
200+
expect(component.remove.emit).toHaveBeenCalledWith('click');
200201
});
201202

202203
it('onRemove: Should remove the element if not disabled', () => {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ export class PoTagComponent extends PoTagBaseComponent implements OnInit {
8686
if (!this.removable && !this.disabled) {
8787
const submittedTagItem = { value: this.value, type: this.type, event: event };
8888
this.click.emit(submittedTagItem);
89+
if (this.poTag && this.poTag.nativeElement) {
90+
this.poTag.nativeElement.focus();
91+
}
8992
}
9093
}
9194

9295
onClose(event = 'click') {
9396
if (!this.disabled) {
94-
this.click.emit(event);
9597
this.onRemove();
9698
this.remove.emit(event);
9799
}

0 commit comments

Comments
 (0)