Skip to content

Commit 504e61c

Browse files
palbizuPatricio Albizu
andauthored
feat: Add formControl disabled to combo-box (#1395)
* feat: Add fromcontrol disabled to combo-box * feat: fixing disabled Co-authored-by: Patricio Albizu <[email protected]>
1 parent fc90cc3 commit 504e61c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

projects/components/src/combo-box/combo-box.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
}
4646
}
4747

48+
&.disabled {
49+
background-color: $gray-2;
50+
.trigger-input {
51+
color: black;
52+
}
53+
}
54+
4855
.trigger-control {
4956
height: 100%;
5057
width: 24px;

projects/components/src/combo-box/combo-box.component.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ import { ComboBoxMode, ComboBoxOption, ComboBoxResult } from './combo-box-api';
3434
}
3535
],
3636
template: `
37-
<ht-popover (popoverOpen)="this.onPopoverOpen($event)" (popoverClose)="this.onPopoverClose()" class="combo-box">
37+
<ht-popover
38+
class="combo-box"
39+
[disabled]="this.disabled"
40+
(popoverOpen)="this.onPopoverOpen($event)"
41+
(popoverClose)="this.onPopoverClose()"
42+
>
3843
<ht-popover-trigger>
3944
<div
4045
#trigger
4146
class="popover-trigger"
4247
[ngClass]="{
4348
input: this.mode === '${ComboBoxMode.Input}',
4449
chip: this.mode === '${ComboBoxMode.Chip}',
45-
'show-border': this.showBorder
50+
'show-border': this.showBorder,
51+
disabled: this.disabled
4652
}"
4753
[class.has-text]="this.text"
4854
[class.input-focused]="input.matches(':focus')"
@@ -79,6 +85,7 @@ import { ComboBoxMode, ComboBoxOption, ComboBoxResult } from './combo-box-api';
7985
8086
<!-- Clear Button -->
8187
<div
88+
*ngIf="!this.disabled"
8289
[class.has-text]="this.text"
8390
[class.input-focused]="input.matches(':focus')"
8491
[ngClass]="this.mode"
@@ -427,6 +434,10 @@ export class ComboBoxComponent<TValue = string> implements AfterViewInit, OnChan
427434
});
428435
}
429436

437+
public setDisabledState(isDisabled?: boolean): void {
438+
this.disabled = isDisabled ?? false;
439+
}
440+
430441
private propagateValueChangeToFormControl(value?: string): void {
431442
this.propagateControlValueChange?.(value);
432443
this.propagateControlValueChangeOnTouch?.(value);

0 commit comments

Comments
 (0)