Skip to content

Commit

Permalink
ICustomQuestionTypeConfiguration: Rename onSetQuestionValue to onValu…
Browse files Browse the repository at this point in the history
…eSet add it to the docs fix #8321
  • Loading branch information
andrewtelnov committed Jun 26, 2024
1 parent c8065bb commit 070b8bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/question_custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export interface ICustomQuestionTypeConfiguration {
* @returns An error text.
*/
getErrorText?: (question: Question) => string;
onValueSet?: (question: Question, newValue: any) => void;
onSetQuestionValue?: (question: Question, newValue: any) => void;
valueToQuestion?: (val: any) => any;
valueFromQuestion?: (val: any) => any;
Expand Down Expand Up @@ -305,8 +306,12 @@ export class ComponentQuestionJSON {
this.json.onUpdateQuestionCssClasses(question, element, css);
}
public onSetQuestionValue(question: Question, newValue: any): void {
if (!this.json.onSetQuestionValue) return;
this.json.onSetQuestionValue(question, newValue);
if (this.json.onSetQuestionValue) {
this.json.onSetQuestionValue(question, newValue);
}
if (this.json.onValueSet) {
this.json.onValueSet(question, newValue);
}
}
public onPropertyChanged(
question: Question,
Expand Down
2 changes: 1 addition & 1 deletion tests/question_customtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3118,7 +3118,7 @@ QUnit.test("Composite: update questions on a value change", function (assert) {
{ type: "dropdown", name: "q2" },
{ type: "text", name: "q3" }
],
onSetQuestionValue: (question, newValue: any): void => {
onValueSet: (question, newValue: any): void => {
if(!!newValue && !!newValue.q3) {
question.contentPanel.getQuestionByName("q2").choices = [newValue.q3];
}
Expand Down

0 comments on commit 070b8bb

Please sign in to comment.