Skip to content

Commit

Permalink
Fixed #492 - onStateChanged not triggering when filters are modified
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed Dec 6, 2024
1 parent cbbf0ed commit cf1fe5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/selectBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ export class SelectBase
item !== undefined ? item.text : ""
);
}
this.stateChanged("filter", this.selectedItem?.value);
}
}
get selection() {
Expand Down
13 changes: 13 additions & 0 deletions tests/selectBase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cf1fe5a

Please sign in to comment.