diff --git a/src/components/select/bl-select.test.ts b/src/components/select/bl-select.test.ts index 9d6bd469..1556b1d5 100644 --- a/src/components/select/bl-select.test.ts +++ b/src/components/select/bl-select.test.ts @@ -158,7 +158,7 @@ describe("bl-select", () => { expect(removeAll).to.exist; expect(event).to.exist; - expect(event.detail).to.eql([]); + expect(event.detail).to.null; expect(el.options.length).to.equal(2); expect(el.selectedOptions.length).to.equal(0); expect(el.value).to.null; @@ -246,7 +246,7 @@ describe("bl-select", () => { const event = await oneEvent(el, "bl-select"); expect(event).to.exist; - expect(event.detail.length).to.equal(1); + expect(event.detail.value).to.equal("1"); expect(el.selectedOptions.length).to.equal(1); }); it("should remove selected item if it is already selected", async () => { diff --git a/src/components/select/bl-select.ts b/src/components/select/bl-select.ts index dbff8254..937ee168 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) {