Skip to content
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
20 changes: 20 additions & 0 deletions e2e/questions/matrixdynamic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,27 @@ frameworks.forEach((framework) => {
const surveyResult = await getSurveyResult(page);
expect(surveyResult).toEqual({ matrix: [{ col1: "row1" }] });
});
test("Matrix focus the first visible and enabled cell on focusing matrix, Bug#10657", async ({ page }) => {
const json = {
elements: [
{ type: "text", name: "q1" },
{ type: "matrixdynamic", name: "matrix", rowCount: 1,
columns: [{ name: "col1", cellType: "text", visible: false }, { name: "col2", cellType: "text" }]
}
]
};
await initSurvey(page, framework, json);
await page.evaluate(() => {
window.survey.getQuestionByName("matrix").focus();
});
await page.waitForTimeout(500);
await page.keyboard.type("row1col2");
await page.keyboard.press("Tab");

await page.click("input[value=Complete]");
const surveyResult = await getSurveyResult(page);
expect(surveyResult).toEqual({ matrix: [{ col2: "row1col2" }] });
});
test("DnD: Matrixdynamic inside Matrixdynamic", async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 1100 });
const json = {
Expand Down
5 changes: 2 additions & 3 deletions packages/survey-core/src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2473,9 +2473,8 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
for (var i = 0; i < this.generatedVisibleRows.length; i++) {
var cells = this.generatedVisibleRows[i].cells;
for (var colIndex = 0; colIndex < cells.length; colIndex++) {
if (!onError) return cells[colIndex].question;
if (cells[colIndex].question.currentErrorCount > 0)
return cells[colIndex].question;
const q = cells[colIndex].question;
if (q.isVisible && !q.isReadOnly && (!onError || q.currentErrorCount > 0)) return q;
}
}
return null;
Expand Down
30 changes: 30 additions & 0 deletions packages/survey-core/tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8334,6 +8334,36 @@ QUnit.test(
SurveyElement.FocusElement = oldFunc;
}
);
QUnit.test("Focus first visible enabled cell on focusing matrix, Bug#10657", (assert) => {
let focusedQuestionId = "";
const oldFunc = SurveyElement.FocusElement;
SurveyElement.FocusElement = function (elId: string): boolean {
focusedQuestionId = elId;
return true;
};

var survey = new SurveyModel({
elements: [
{
type: "matrixdynamic",
name: "matrix",
cellType: "text",
rowCount: 1,
columns: [
{ name: "col1", visible: false },
{ name: "col2", readOnly: true },
{ name: "col3" },
{ name: "col4" },
],
},
],
});
const matrix = <QuestionMatrixDynamicModel>survey.getQuestionByName("matrix");
const rows = matrix.visibleRows;
matrix.focus();
assert.equal(focusedQuestionId, rows[0].cells[2].question.inputId, "focus correct value");
SurveyElement.FocusElement = oldFunc;
});
QUnit.test(
"Matrixdynamic onMatrixValueChanging - do not call event on clear empty cell",
function (assert) {
Expand Down