Skip to content

Commit

Permalink
goNextPageAutomatic and showOtherItem are not working well together fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jan 16, 2024
1 parent 34effef commit 69224cc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/question_dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class QuestionDropdownModel extends QuestionSelectBase {
}
}
supportGoNextPageAutomatic(): boolean {
return true;
return !this.isOtherSelected;
}
private minMaxChoices = <Array<ItemValue>>[];
protected getChoices(): Array<ItemValue> {
Expand Down
2 changes: 1 addition & 1 deletion src/question_radiogroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class QuestionRadiogroupModel extends QuestionCheckboxBase {
return this.getLocalizationString("clearCaption");
}
supportGoNextPageAutomatic(): boolean {
return this.isMouseDown === true;
return this.isMouseDown === true && !this.isOtherSelected;
}
protected setNewComment(newValue: string): void {
this.isMouseDown = true;
Expand Down
7 changes: 5 additions & 2 deletions tests/surveyquestiontests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,14 @@ QUnit.test("Radiogroup Question: support goNextPageAutomatic + hasOther", functi
goNextPageAutomatic: true,
};
const survey = new SurveyModel(json);
const question = survey.getQuestionByName("q1");
const question = <QuestionRadiogroupModel>survey.getQuestionByName("q1");
question.value = "other";
assert.equal(survey.currentPageNo, 0, "Stay on the first page");
question.comment = "123";
assert.equal(survey.currentPageNo, 1, "Go to the second page");
assert.equal(survey.currentPageNo, 0, "Still stay on the page");
question.onMouseDown();
question.value = 2;
assert.equal(survey.currentPageNo, 1, "Go to the next page");
});

QUnit.test(
Expand Down
4 changes: 4 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,8 @@ QUnit.test("Should not show errors with others bug #2014", function (assert) {
assert.equal(survey.currentPageNo, 0, "The page is still first");
assert.equal(question.errors.length, 0, "Do not show any error");
question.comment = "Some text";
assert.equal(survey.currentPageNo, 0, "The page is still first, #2");
question.value = 2;
assert.equal(survey.currentPageNo, 1, "The second page is shown");
});
QUnit.test(
Expand Down Expand Up @@ -3906,6 +3908,8 @@ QUnit.test("test goNextPageAutomatic property", function (assert) {
);
assert.notEqual(survey.state, "completed", "survey is still running");
dropDownQ.comment = "other value";
assert.notEqual(survey.state, "completed", "survey is still running #2");
dropDownQ.value = 1;
assert.equal(survey.state, "completed", "complete the survey");
});
QUnit.test("test goNextPageAutomatic property for boolean/switch", function (
Expand Down

0 comments on commit 69224cc

Please sign in to comment.