Skip to content

Commit

Permalink
fix(select): return value instead of array on single select
Browse files Browse the repository at this point in the history
  • Loading branch information
0o001 committed Dec 23, 2023
1 parent ecc8a30 commit df920ee
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/components/select/bl-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ export default class BlSelect<ValueType extends FormValue = string> extends Form
/**
* Fires when selection changes
*/
@event("bl-select") private _onBlSelect: EventDispatcher<ISelectOption<ValueType>[]>;

@event("bl-select") private _onBlSelect: EventDispatcher<
ISelectOption<ValueType> | ISelectOption<ValueType>[]
>;
private _connectedOptions: BlSelectOption<ValueType>[] = [];

private _cleanUpPopover: CleanUpFunction | null = null;
Expand Down Expand Up @@ -441,16 +442,16 @@ export default class BlSelect<ValueType extends FormValue = string> extends Form
}

private _handleSelectEvent() {
this._onBlSelect(
this._selectedOptions.map(
option =>
({
value: option.value,
selected: option.selected,
text: option.textContent,
} as ISelectOption<ValueType>)
)
const selectedOptions = this._selectedOptions.map(
option =>
({
value: option.value,
selected: option.selected,
text: option.textContent,
} as ISelectOption<ValueType>)
);

this._onBlSelect(this.multiple ? selectedOptions : selectedOptions[0]);
}

private _handleSingleSelect(optionItem: BlSelectOption<ValueType>) {
Expand Down

0 comments on commit df920ee

Please sign in to comment.