diff --git a/src/selectBase.ts b/src/selectBase.ts index 364a04048..d9ea565dc 100644 --- a/src/selectBase.ts +++ b/src/selectBase.ts @@ -350,6 +350,7 @@ export class SelectBase item !== undefined ? item.text : "" ); } + this.stateChanged("filter", this.selectedItem?.value); } } get selection() { diff --git a/tests/selectBase.test.ts b/tests/selectBase.test.ts index d35838e43..561b4e4af 100644 --- a/tests/selectBase.test.ts +++ b/tests/selectBase.test.ts @@ -91,6 +91,19 @@ test("setSelection", () => { expect(lastText).toEqual("True"); }); +test("onStateChanged reised on setSelection", () => { + let log = ""; + selectBase.onStateChanged.add((s, o) => { + log += "->" + o.filter; + }); + + selectBase.setSelection(new ItemValue(1, "One")); + expect(log).toEqual("->1"); + + selectBase.setSelection(undefined as any); + expect(log).toEqual("->1->undefined"); +}); + test("set answersOrder triggers renderContent and update", () => { selectBase.render(document.createElement("div")); let updateCallCount = 0;