Skip to content

Commit

Permalink
feat: add input option to select component to emit on select input ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
jake-bassett committed Jan 4, 2024
1 parent 7080b66 commit 8cda34d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions projects/components/src/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
@Input()
public triggerDisplayMode?: SelectTriggerDisplayMode = SelectTriggerDisplayMode.MenuWithBorder;

@Input()
public emitOnSelectedChange: boolean = false; // Call selectedChange Output() when selected Input() is updated

@Input()
public placeholder?: string;

Expand Down Expand Up @@ -311,6 +314,9 @@ export class SelectComponent<V> implements ControlValueAccessor, AfterContentIni
if (this.allOptionsList !== undefined && changes.selected !== undefined) {
this.selected$ = this.buildObservableOfSelected();
}
if (this.emitOnSelectedChange && changes.selected?.previousValue !== changes.selected?.currentValue) {
this.selectedChange.emit(this.selected);

Check warning on line 318 in projects/components/src/select/select.component.ts

View check run for this annotation

Codecov / codecov/patch

projects/components/src/select/select.component.ts#L318

Added line #L318 was not covered by tests
}
}

public isSelectedItem(item: SelectOptionComponent<V>): boolean {
Expand Down

0 comments on commit 8cda34d

Please sign in to comment.