Skip to content

Commit

Permalink
A click on a toolbox item inserts a new question at the end of the page
Browse files Browse the repository at this point in the history
fix #5674 (#5695)
  • Loading branch information
andrewtelnov authored Jul 16, 2024
1 parent d26815c commit 2bfe290
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ export class SurveyCreatorModel extends Base
}
parent = selectedElement.parent;
if (index < 0) {
if (this.addNewQuestionLast) {
if (this.addNewQuestionLast && modifiedType === "ADDED_FROM_PAGEBUTTON") {
index = parent.elements.length;
} else {
index = parent.elements.indexOf(selectedElement);
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-creator-core/tests/creator-base.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3900,12 +3900,12 @@ test("creator.addNewQuestionLast property", (): any => {
creator.clickToolboxItem({ type: "text" });
expect(creator.selectedElementName).toEqual("question2");
creator.selectQuestionByName("question1");
creator.clickToolboxItem({ type: "text" });
creator.addNewQuestionInPage((str) => {}, undefined, "text");
expect(creator.selectedElementName).toEqual("question3");
expect(creator.survey.pages[0].elements[2].name).toEqual("question3");
creator.selectQuestionByName("question1");
creator.addNewQuestionLast = false;
creator.clickToolboxItem({ type: "text" });
creator.addNewQuestionInPage((str) => {}, undefined, "text");
expect(creator.selectedElementName).toEqual("question4");
expect(creator.survey.pages[0].elements[1].name).toEqual("question4");
expect(creator.survey.pages[0].elements[3].name).toEqual("question3");
Expand Down

0 comments on commit 2bfe290

Please sign in to comment.