Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Do not call notification on setting the same value in select bas… #3161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ export class QuestionSelectBase extends Question {
}
public set renderedValue(val: any) {
this.setPropertyValue("renderedValue", val);
this.value = this.rendredValueToData(val);
var val = this.rendredValueToData(val);
if (!Helpers.isTwoValueEquals(val, this.value)) {
this.value = val;
}
}
protected setQuestionValue(
newValue: any,
Expand Down
39 changes: 39 additions & 0 deletions tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6765,3 +6765,42 @@ QUnit.test(
assert.equal(counter, 1, "value is correct");
}
);
QUnit.test(
"Matrixdynamic onMatrixValueChanging - do not call event on set the same renderedValue",
function(assert) {
var json = {
questions: [
{
type: "matrixdynamic",
name: "q1",
rowCount: 1,
columns: [
{
name: "col1",
choices: [1, 2, 3, 4, 5],
},
],
},
],
};
var survey = new SurveyModel(json);
var counter = 0;
survey.onMatrixCellValueChanging.add(function(sender, options) {
counter++;
});
var matrix = <QuestionMatrixDynamicModel>survey.getQuestionByName("q1");
var cellQuestion = <QuestionDropdownModel>(
matrix.visibleRows[0].cells[0].question
);
cellQuestion.renderedValue = undefined;
assert.equal(counter, 0, "There is not value to clear");
cellQuestion.renderedValue = 1;
assert.equal(counter, 1, "Call one time");
cellQuestion.renderedValue = 1;
assert.equal(counter, 1, "Do not call on the same value");
cellQuestion.renderedValue = undefined;
assert.equal(counter, 2, "Value is undefined");
cellQuestion.renderedValue = undefined;
assert.equal(counter, 2, "Value is still undefined");
}
);