From 44bd72b4df8acfbf062a2cf7c2b4364c03f823ea Mon Sep 17 00:00:00 2001 From: Vicki League Date: Wed, 25 Jun 2025 16:54:56 -0400 Subject: [PATCH] select module improvements --- libs/components/src/select/option.component.ts | 8 ++++---- libs/components/src/select/select.component.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/components/src/select/option.component.ts b/libs/components/src/select/option.component.ts index 1ffdc3f9320..39671b57221 100644 --- a/libs/components/src/select/option.component.ts +++ b/libs/components/src/select/option.component.ts @@ -9,11 +9,11 @@ import { MappedOptionComponent } from "./option"; template: ``, }) export class OptionComponent implements MappedOptionComponent { - icon = input(); + readonly icon = input(); - value = input.required(); + readonly value = input.required(); - label = input.required(); + readonly label = input.required(); - disabled = input(undefined, { transform: booleanAttribute }); + readonly disabled = input(undefined, { transform: booleanAttribute }); } diff --git a/libs/components/src/select/select.component.ts b/libs/components/src/select/select.component.ts index 1ddd2f322df..f0c707f3b36 100644 --- a/libs/components/src/select/select.component.ts +++ b/libs/components/src/select/select.component.ts @@ -42,14 +42,14 @@ let nextId = 0; providers: [{ provide: BitFormFieldControl, useExisting: SelectComponent }], imports: [NgSelectModule, ReactiveFormsModule, FormsModule], host: { - "[id]": "this.id()", + "[id]": "id()", }, }) export class SelectComponent implements BitFormFieldControl, ControlValueAccessor { @ViewChild(NgSelectComponent) select: NgSelectComponent; /** Optional: Options can be provided using an array input or using `bit-option` */ - items = model[]>(); + items = model[] | undefined>(); readonly placeholder = input(this.i18nService.t("selectPlaceholder")); @Output() closed = new EventEmitter(); @@ -162,7 +162,7 @@ export class SelectComponent implements BitFormFieldControl, ControlValueAcce } /**Implemented as part of BitFormFieldControl */ - id = input(`bit-multi-select-${nextId++}`); + readonly id = input(`bit-multi-select-${nextId++}`); /**Implemented as part of BitFormFieldControl */ // TODO: Skipped for migration because: @@ -188,8 +188,8 @@ export class SelectComponent implements BitFormFieldControl, ControlValueAcce return [key, this.ngControl?.errors[key]]; } - private findSelectedOption(items: Option[], value: T): Option | undefined { - return items.find((item) => item.value === value); + private findSelectedOption(items: Option[] | undefined, value: T): Option | undefined { + return items?.find((item) => item.value === value); } /**Emits the closed event. */