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

Dynamic Matrix with Signature Pad in a detail form - The Clear button… #9172

Merged
merged 1 commit into from
Dec 16, 2024
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
18 changes: 6 additions & 12 deletions packages/survey-core/src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2447,21 +2447,15 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
this.isValueInColumnDuplicated(columnName, !!rowObj);
}
}
private getNewValueOnRowChanged(
row: MatrixDropdownRowModelBase,
columnName: string,
newRowValue: any,
isDeletingValue: boolean,
newValue: any
): any {
var rowValue = this.getRowValueCore(row, newValue, true);
private getNewValueOnRowChanged(row: MatrixDropdownRowModelBase,
columnName: string, newRowValue: any, isDeletingValue: boolean, newValue: any): any {
const rowValue = this.getRowValueCore(row, newValue, true);
if (isDeletingValue) {
delete rowValue[columnName];
}
for (var i = 0; i < row.cells.length; i++) {
var key = row.cells[i].question.getValueName();
delete rowValue[key];
}
row.questions.forEach(q => {
delete rowValue[q.getValueName()];
});
if (newRowValue) {
newRowValue = JSON.parse(JSON.stringify(newRowValue));
for (var key in newRowValue) {
Expand Down
31 changes: 31 additions & 0 deletions packages/survey-core/tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7309,6 +7309,37 @@ QUnit.test("Detail panel, Process text in titles", function (assert) {
"Text preprocessed correctly"
);
});
QUnit.test("Detail panel & survey.onValueChanged & empty value, Bug#9169", function (assert) {
const survey = new SurveyModel({
elements: [
{
type: "matrixdynamic",
name: "matrix",
rowCount: 2,
detailPanelMode: "underRow",
columns: [{ name: "col1" }, { name: "col2" }],
detailElements: [
{ type: "text", name: "q1" }
]
}
]
});
const matrix = <QuestionMatrixDynamicModel>survey.getQuestionByName("matrix");

matrix.visibleRows[0].showDetailPanel();
const q1 = matrix.visibleRows[0].detailPanel.getQuestionByName("q1");
const logs: any = [];
survey.onValueChanged.add((sender, options) => {
logs.push({ name: options.name, value: options.value });
});
q1.value = "abc";
assert.deepEqual(logs, [{ name: "matrix", value: [{ q1: "abc" }, {}] }], "#1");
q1.clearValue();
assert.deepEqual(logs, [
{ name: "matrix", value: [{ q1: "abc" }, {}] },
{ name: "matrix", value: [] }
], "#2");
});

QUnit.test("copyvalue trigger for dropdown matrix cell", function (assert) {
var survey = new SurveyModel({
Expand Down
Loading