Skip to content

Commit

Permalink
fix: autocomplete label
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninoBonanno authored Feb 8, 2024
1 parent 3bfe2b4 commit c7271f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<div class="form-group" [class.autocomplete-wrapper-big]="big">
@if (label) {
<label [for]="id" class="visually-hidden">{{ label }}</label>
<label [for]="id" [class.visually-hidden]="!isActiveLabel" [class.active]="isActiveLabel">
{{ label }}
</label>
}

<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class ItAutocompleteComponent extends ItAbstractFormComponent<string | nu
*/
@Input() placeholder = '';

/**
* Show the label
*/
@Input({ transform: inputToBoolean }) forceShowLabel: boolean = true;

/**
* Fired when the Autocomplete Item has been selected
*/
Expand Down Expand Up @@ -112,4 +117,9 @@ export class ItAutocompleteComponent extends ItAbstractFormComponent<string | nu
protected onKeyDown() {
this.showAutocompletion = true;
}

protected get isActiveLabel(): boolean {
const value = this.control.value;
return this.forceShowLabel && (!!value || !!this.placeholder);
}
}

0 comments on commit c7271f0

Please sign in to comment.