Skip to content

Commit a82742f

Browse files
authored
Merge pull request #731 from dxc-technology/fix-disabled-tag
[Patch] Fixed tag when disabled and has actions
2 parents e29db00 + e7982f8 commit a82742f

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/previews/tag-preview/tag-preview.component.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,27 @@
6262
<img src="{{ dxcLogoPath }}" />
6363
</dxc-tag-icon>
6464
</dxc-tag>
65+
66+
<dxc-tag
67+
margin="xsmall"
68+
label="DXC TECHNOLOGY"
69+
disabled="true"
70+
linkHref="www.google.es"
71+
>
72+
<dxc-tag-icon>
73+
<img src="{{ dxcLogoPath }}" />
74+
</dxc-tag-icon>
75+
</dxc-tag>
76+
77+
<dxc-tag
78+
margin="xsmall"
79+
label="DXC TECHNOLOGY"
80+
(onClick)="onClick()"
81+
disabled="true"
82+
>
83+
<dxc-tag-icon>
84+
<img src="{{ dxcLogoPath }}" />
85+
</dxc-tag-icon>
86+
</dxc-tag>
6587
</tbuilder-component-mode>
6688
</div>

projects/dxc-ngx-cdk-site/src/app/pages/theme-builder/previews/tag-preview/tag-preview.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ export class TagPreviewComponent implements OnInit {
1212

1313
ngOnInit(): void {}
1414

15-
onClick() {}
15+
onClick() {
16+
console.log("click");
17+
}
1618
}

projects/dxc-ngx-cdk/src/lib/dxc-tag/dxc-tag.component.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ export class DxcTagComponent implements OnInit {
197197
};
198198

199199
public onClickHandler($event: any): void {
200-
this.onClick.emit($event);
200+
if (!this.disabled) {
201+
this.onClick.emit($event);
202+
}
201203
}
202204

203205
getShadowDepth(): string {
@@ -236,17 +238,17 @@ export class DxcTagComponent implements OnInit {
236238
getDynamicStyle(inputs) {
237239
return css`
238240
display: inline-flex;
239-
${inputs.disabled
241+
${!this.isClickDefined &&
242+
(this.linkHref === null || this.linkHref === undefined)
240243
? css`
241-
cursor: not-allowed;
244+
cursor: unset;
242245
`
243-
: this.isClickDefined ||
244-
(this.linkHref !== null && this.linkHref !== undefined)
246+
: this.disabled
245247
? css`
246-
cursor: pointer;
248+
cursor: not-allowed;
247249
`
248250
: css`
249-
cursor: unset;
251+
cursor: pointer;
250252
`};
251253
${this.utils.getMargins(inputs.margin)};
252254
dxc-box {
@@ -317,12 +319,14 @@ export class DxcTagComponent implements OnInit {
317319
background: none;
318320
border: none;
319321
padding: 0;
320-
cursor: pointer;
322+
cursor: ${!this.disabled ? "pointer" : "not-allowed"};
321323
outline: 0;
322324
}
323325
.styledLink {
324326
text-decoration: none;
325327
outline: none;
328+
cursor: ${!this.disabled ? "pointer" : "not-allowed"};
329+
${this.disabled ? "pointer-events: none;" : ""}
326330
}
327331
${this.setActionStyle(inputs)};
328332
`;

0 commit comments

Comments
 (0)