From df920eea8368b7e98b18dd20c84fe43b4da071f0 Mon Sep 17 00:00:00 2001 From: Mustafa UZUN Date: Sun, 24 Dec 2023 00:28:53 +0300 Subject: [PATCH] fix(select): return value instead of array on single select https://github.com/Trendyol/baklava/issues/675 --- src/components/select/bl-select.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/select/bl-select.ts b/src/components/select/bl-select.ts index dbff82547..937ee168c 100644 --- a/src/components/select/bl-select.ts +++ b/src/components/select/bl-select.ts @@ -178,8 +178,9 @@ export default class BlSelect extends Form /** * Fires when selection changes */ - @event("bl-select") private _onBlSelect: EventDispatcher[]>; - + @event("bl-select") private _onBlSelect: EventDispatcher< + ISelectOption | ISelectOption[] + >; private _connectedOptions: BlSelectOption[] = []; private _cleanUpPopover: CleanUpFunction | null = null; @@ -441,16 +442,16 @@ export default class BlSelect extends Form } private _handleSelectEvent() { - this._onBlSelect( - this._selectedOptions.map( - option => - ({ - value: option.value, - selected: option.selected, - text: option.textContent, - } as ISelectOption) - ) + const selectedOptions = this._selectedOptions.map( + option => + ({ + value: option.value, + selected: option.selected, + text: option.textContent, + } as ISelectOption) ); + + this._onBlSelect(this.multiple ? selectedOptions : selectedOptions[0]); } private _handleSingleSelect(optionItem: BlSelectOption) {